This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Hi,

I'm making a small 3d renderer for fun. I just added a sphere primitive. I applied a rotation transform to make it appear as if it's sitting at a 30 degree angle (like our planet, kind of). I'd like to just keep rotating it around its axis now every frame of animatin, but it appears that when I am applying my transform of 3 degrees around the y axis, it's doing it around the global origin - so it looks like the axis of the sphere is actually pointing in different directions while rotating.

I'm not sure what the best solution is - should I implement a rotateSelf() function which applies a transform about the object's current origin? Or is there some other way?

Thanks

I'm making a small 3d renderer for fun. I just added a sphere primitive. I applied a rotation transform to make it appear as if it's sitting at a 30 degree angle (like our planet, kind of). I'd like to just keep rotating it around its axis now every frame of animatin, but it appears that when I am applying my transform of 3 degrees around the y axis, it's doing it around the global origin - so it looks like the axis of the sphere is actually pointing in different directions while rotating.

I'm not sure what the best solution is - should I implement a rotateSelf() function which applies a transform about the object's current origin? Or is there some other way?

Thanks

matrix createRotationMatrixAxisX(

and the other axes .. but i guess you already have that, right? :)

of course you can create the rotateSelf() func as well, but it will hide the important part, the matrix-transform-chain ..

then a rotation by 3 degrees around that axis is a multiply by

1+(1-cos(pi*3/180))*(x*x-1

(1-cos(pi*3/180))*x*y 1+(1-cos(pi*3/180))*(y*y-1

-y*sin(pi*3/180)z x*sin(pi*3/180) cos(pi*3/180))

I may have implemented my library incorrectly. When I apply a transformation to the vertices of my object, the vertices get transformed ok, that's not a problem. But the vertices are - well - transformed now to some new location.

So if on the subsequent animation frame I try applying the tilt matrix AGAIN, it will keep making the vertices tilt even more. Instead of keeping a constant 30 degree tilt on the z-axis, it will appear to rotate by 30 degrees around the z-axis with every animation frame!

Should I implement this somewhat differently?

Thanks

A rotation will always transform vertices to some new location, unless a vertex is on the axis of rotation or the rotation is by a multiple of 2pi

> So if on the subsequent animation frame I try applying the tilt matrix AGAIN,

Don't you want to apply the rotation matrix again, not the tilt matrix again?

The tilt matrix cab be used to derive the proper rotation matrix.

Option 1:

create object with vertices centered around world origin

apply matrix, vertex locations are modified

draw to screen using modified vertex locations

Option 2:

create object with vertices centered around world origin

apply matrix, vertex locations are NOT modified

draw to screen by constantly applying internal transformation matrix to unmodified original points

which is the right way to go?

Yeah I just want to apply the rotation matrix over and over again - but I don't understand this:

1+(1-cos(pi*3/180))*(x*x-1

(1-cos(pi*3/180))*x*y 1+(1-cos(pi*3/180))*(y*y-1

-y*sin(pi*3/180)z x*sin(pi*3/180) cos(pi*3/180))

do you mean I should create a new empty matrix and fill each row/col with those values then apply it to my sphere?

Thanks

if you multply it by the coordinates of a vertex, the result will be the coordinates

after a rotation by 3 degrees around an axis defined by the unit vector in the (x,y,0) direction

neither 1 nor 2 :)

> create object with vertices centered around world origin

create the points of the object centered around its own center of mass .. if you have an airplane, it should roll/pitch around its own center of mass, its own {0,0,0} point or origin. keep those points during all the program, dont change them. rather in the begin each frame copy them to another buffer of the same size (so each object should hold 2 buffers of points, the original and the transformed in each frame). in each frame compute the movements of the airplane, its roll/pitch and stuff, apply it to the second buffer and apply its position to that buffer and render it at the end of the frame ..

the same answer, like in your other q: http://www.experts-exchange.com/Programming/Game/3D_Prog./Q_22865584.html

ike

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

> I'm not sure what the best solution is - should I implement a rotateSelf() function which applies a transform about the object's current origin?

you can do that, but one essence of 3d-programming is to learn how to use matrices, to do your desired transformations..

here is how you can do it, you need 3 matrices:

M_30_deg -> 30 degrees rotation around axis z (as if it's sitting at a 30 degree angle (like our planet, kind of)

M_mod -> modulated rotation around axis y (for rotating around its own axis)

now multiply both matrices in this order each frame:

M_current_frame = M_30_deg * M_mod

and multiply that matrix with your object's vertices, that's it .. :)

the rotateSelf()-function would multiply the M_mod-matrix with the object's-vertices first and after that you would multiply the M_30_deg-matrix with the object's vertices.. that works as well, but wouldn't be so nice, since you have a double amount matrix-vertex-multiplicati

rather than the rotateSelf()-function i'd recommend to put a applyMatrix()-function to your object and create the matrix-transform-chain first with matrices and multiply them, to get the final matrix and at the end apply the final matrix to your object ..

ike