Question about rotations off 90 degrees

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
211
Reaction score
0
Points
0
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Hi There,

wondering if anyone had a similar issue and found a fix. I am trying to code an animation that rotates not along X, Y or Z axis by 90 degrees, but rather along both the X and Z axis (essentially rotating along an axis 45 degrees from Z, if that makes sense, here is the code I have for it:

static MGROUP_ROTATE mgt_leftgearclaw1 (Mesh_Main, &RearGearLeftClaw1, 1, _V(-78.16914, -53.25367, -20.11191), _V( 0.5, 0.0, 0.5), (float)85*RAD);
however like this the animated group appears distorted and misshaped when I reload the scenario to current state.

Does anyone know why this might be happening?

Thanks in advance :)
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
35,590
Reaction score
97
Points
138
Location
Langendernbach
Yes, the problem is, that your direction vector is not normalized to length 1.0. That causes distortions.

For what you want to achieve, the simplest way to create such a vector is defining a constant with the value: _V(1.0, 0.0, 1.0)/sqrt(2.0)

or : _V(1.0/sqrt(2.0), 0.0, 1.0/sqrt(2.0))
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
618
Reaction score
44
Points
28
Location
This place called "home".
Or simply use the API function unit() (or normalise() if you need the normalised vector several times).

So something like this:
Code:
static MGROUP_ROTATE mgt_leftgearclaw1(
	Mesh_Main, 
	&RearGearLeftClaw1, 1, 
	_V(-78.16914, -53.25367, -20.11191),
	[I]unit(_V( 0.5, 0.0, 0.5)),[/I]
	(float)85*RAD
);
 

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
211
Reaction score
0
Points
0
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Thank You!

Yes, the problem is, that your direction vector is not normalized to length 1.0. That causes distortions.

For what you want to achieve, the simplest way to create such a vector is defining a constant with the value: _V(1.0, 0.0, 1.0)/sqrt(2.0)

or : _V(1.0/sqrt(2.0), 0.0, 1.0/sqrt(2.0))
Thanks so much Urwumpe! that's a big help!
 
Top