Author Topic: Rotating static shapes  (Read 1605 times)

if you know me you'll already know that i suck at angles and vectors and rotation and stuff

Code: [Select]
function gencircle(%obj)
{
%f = 360;
for(%i = 0; %i < %f; %i++)
{
new StaticShape(ab)
{
datablock = cube;
position = getWord(%obj.getPosition(),0)+(msin((%i*180)/$pi)*10) SPC getWord(%obj.getPosition(),1)+(mcos((%i*180)/$pi)*10) SPC 0;
scale = "0.2 1 10";
};
ab.setTransform(ab.getposition() SPC 0 SPC eulerToAxis(%i) SPC 0);
}
}
this spawns 359 static shapes in a circle around an object. I need each static object to FACE the ORIGIN of the circle.

Someone help me out

so given that the way blockland and many other programs do 3d rotations (aka with quaternions, the last four values in a getTransform) in order to get a solution one needs a bit more information regarding how this circle is oriented

is it always along the xy plane? or does it have some angle that makes one end point higher than the others?

the general approach is to vector cross the direction you need the object to face with a vector representing the direction that points "forward" on the static shape, and then calculate how much rotation around the vector cross is needed. however this can result in some gimballing of the shape if it ends up pointing downwards or such.

yeah its a circle around an object along the xy plane, so it's a circle, not a sphere

also i have no clue how to do any vector math and i suck richard at it

ill help you tomorrow if there are no responses by then

at home and i left my pc at my apartment

euler to axis works like this
eulerToAxis("x y z");

and a 4 word axis rotation is returned

wouldn't it be ab.setTransform(ab.getposition() SPC eulerToAxis(0 SPC %i SPC 0));?

wouldn't it be ab.setTransform(ab.getposition() SPC eulerToAxis(0 SPC %i SPC 0));?
euler to axis works like this
eulerToAxis("x y z");

and a 4 word axis rotation is returned

glooks
« Last Edit: January 29, 2017, 05:16:29 AM by PhantOS »