Results 1 to 6 of 6

Thread: GDIPLUS: can i rotate on diferent way?

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    GDIPLUS: can i rotate on diferent way?

    using Matrix.RoateAt(), we can rotate the image like the clock.
    but we can rotate on horizontal and vertical way?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,904

    Re: GDIPLUS: can i rotate on diferent way?


  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: GDIPLUS: can i rotate on diferent way?

    i use Matrix.RotateAt(). so is rotated like the analog clock pointer.
    my question is: can i rotate it on vertical and horizontal?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: GDIPLUS: can i rotate on diferent way?

    It can be done but you need 3 things:
    1. A basic knowledge of trigonometry (Sin and Cos).
    2. A good 3D imagination.
    3. A basic understanding of 3D geometry. Mostly that's the same as 2, so you really only need 2.5 things.

    Here's an example of how you need to think. Suppose you have a drawing which is a square of 300 x 300 pixels. It's at the centre of your Form drawing area. Let's assume that the X axis lies on the screen surface and the screen is at distance Z0 from your eye.

    In your imagination, tilt the square 30 degrees forwards around the X axis. That means the top corners of the square come forwards out of the screen and the bottom corners go back behind the screen. Can you work out the resulting 3D positions (x, y, z) of the corners of the square?

    Here are some hints:
    1. The X coordinates of the corners don't change in 3D space (as long as you only rotate the square around the X axis).
    2. Try to think of how it looks when you view it from the side (along the X axis).

    If you can work out the (x, y, z) positions, it won't be hard how to draw the tilted square on the screen, as I explained in your thread about the Z positions.

    BB

    EDIT (red above) was an error which I tried to correct earlier; see also Passel's message.

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: GDIPLUS: can i rotate on diferent way?

    Quote Originally Posted by boops boops View Post
    ...
    1. The y positions don't change in 3D space (as long as you only rotate the square around the X axis).
    ...
    I'm not sure what "y positions" is referring to here.
    Normally x,y,z are coordinates of a point and when you rotate a point around any axis, e.g. the X axis, the position of the other two coordinate, i.e. Y and Z have to be computed. If you rotate around the X axis, the X coordinate doesn't change, but the other two do.
    Likewise, rotation around Z affects X,Y which would be your standard two dimensional coordinate system rotation, i.e. what the GDI+ matrix provides. Essentially all your Z coordinate values are always 0, and you are rotating the drawing around a Z axis.

    Of course using the rotation around X axis example, while the X coordinate doesn't change, if you are displaying with perspective then where the X coordinate is displayed does change, i.e. the size in X expands if it is closer to you or shrinks if it is further from you.

    If 3D rotation is what joaquim is referring to (and I wasn't sure so didn't respond to the question on the 30th), then technically the answer is no. You can't use the GDI+ Matrix directly to do 3d rotations.
    If you want to do 3d rotations, then the best bet would be to use a wpf project instead of a winform project.
    The alternative would be to do calculations and drawing yourself, which I think is what boops boops is saying, or use code that someone else has already done to provide that capability, or not use GDI+ and use some other 3d graphics library.

  6. #6
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: GDIPLUS: can i rotate on diferent way?

    Quote Originally Posted by passel View Post
    I'm not sure what "y positions" is referring to here.
    That should have been X of course, not Y. (Excuse: I tried to correct itjust after posting but my internet connection went down)

    BB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width