Rotation around Arbitrary Axis

Posted By: Ralaman

Rotation around Arbitrary Axis - 04/12/11 01:13

Anyone know how to rotate a entity around arbitrary axis.
Like the moon arround the earth?

thx
Posted By: FoxHound

Re: Rotation around Arbitrary Axis - 04/12/11 01:24

I like to use cos and sin but vec_rotate is pretty good
Posted By: Ralaman

Re: Rotation around Arbitrary Axis - 04/12/11 01:25

Can u show me a exemple plz?
Posted By: FoxHound

Re: Rotation around Arbitrary Axis - 04/12/11 01:30

When o get on a computer And not my phone I can. Till then check the manual.
Posted By: Ralaman

Re: Rotation around Arbitrary Axis - 04/12/11 01:31

Well i worked i little whit vec_rotate but i dont get the right solution yet =(

And that add me another problem... i want my entity to pan correctly following the rotation arround the axis.

How i can add a image to the post? It need to be in a http link?
Posted By: 3run

Re: Rotation around Arbitrary Axis - 04/12/11 05:54

Simply like this:
Code:
var offset = -100; // decrease to increase distance
camera.pan += 10 * time_step;
camera.x = my.x + fcos((camera.pan),fcos(camera.tilt,offset));
camera.y = my.y + fsin((camera.pan),fcos(camera.tilt,offset));
camera.z = my.z + 40 + fsin(camera.tilt,offset);

This example shows how to make camera that moves around the player (MY);
Posted By: muffel

Re: Rotation around Arbitrary Axis - 04/12/11 15:44

Quaternion or simple use this function:

ang_for_axis(ANGLE* vAng, VECTOR* vAxis, var angle)

muffel
Posted By: FoxHound

Re: Rotation around Arbitrary Axis - 04/12/11 16:37

Another way to set up the camera easily is

camera.x = my.x + 200 * cos(my.pan)
camera.y = my.y + 200 * sin(my.pan)
As is the camera will move around the player but the pan of the camera won't pan. Throw in Camera.pan = player.pan; and it will fix that.

try

camera.x = my.x + 200 * cos(camera.pan)
camera.y = my.y + 200 * sin(camera.pan)
camera.pan += well anything

That way you can choose in another way how to orbit the camera or anything for that matter around a point.
© 2023 lite-C Forums