Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

trigonometry

gamerogamero Member Posts: 11
I'm trying to create an application using Direct3D. I have a cylinder in a vertexbuffer (a narrow cylinder, think of it as a line), with the ends at 0,0,0 and 1,0,0. Now, i need to rotate it so that it is rendered with one end at point x1,y1,z1 and the other at point x2,y2,z2 in the world space (the points will move around a lot). I have managed to scale it so that it has the correct length, translate it so it starts at the right point, and even rotate it around the z-axis correctly, but the rotation around the x and y axis wont work.

So, i need to use D3DXMatrixRotationYawPitchRoll(), right? How do i calculate the angles?

Comments

  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : I'm trying to create an application using Direct3D. I have a cylinder in a vertexbuffer (a narrow cylinder, think of it as a line), with the ends at 0,0,0 and 1,0,0. Now, i need to rotate it so that it is rendered with one end at point x1,y1,z1 and the other at point x2,y2,z2 in the world space (the points will move around a lot). I have managed to scale it so that it has the correct length, translate it so it starts at the right point, and even rotate it around the z-axis correctly, but the rotation around the x and y axis wont work.
    :
    : So, i need to use D3DXMatrixRotationYawPitchRoll(), right? How do i calculate the angles?
    :
    I would try on our DirectX forum. I am an OpenGL person myself, so I can't help you unfortunatly :/.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • gautamgautam Member Posts: 642
    : : I'm trying to create an application using Direct3D. I have a cylinder in a vertexbuffer (a narrow cylinder, think of it as a line), with the ends at 0,0,0 and 1,0,0. Now, i need to rotate it so that it is rendered with one end at point x1,y1,z1 and the other at point x2,y2,z2 in the world space (the points will move around a lot). I have managed to scale it so that it has the correct length, translate it so it starts at the right point, and even rotate it around the z-axis correctly, but the rotation around the x and y axis wont work.
    : :
    : : So, i need to use D3DXMatrixRotationYawPitchRoll(), right? How do i calculate the angles?
    : :
    : I would try on our DirectX forum. I am an OpenGL person myself, so I can't help you unfortunatly :/.
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :

    Use the dot product and cross product between 2 lines to get the angles.If I remember correctly

    AxB = A.B cos (angle)

    To get the vectors A and B you will have the project the point onto the particular planes.

    I know the math but I can't help you with DirectX functions.


Sign In or Register to comment.