Yrot calculation
#1

I've spent the whole evening trying to figure it out, but just can't come up with a formula. Could anyone help me, when Coordinates of two objects are known, X1rot and Z1rot are also known.

NEED: Y1Rot(to face object2)
Reply
#2

So what do you want ? Y Rotation of an object ?
GetObjectRot();
Reply
#3

Quote:
Originally Posted by Drebin
Посмотреть сообщение
So what do you want ? Y Rotation of an object ?
GetObjectRot();
I want to calculate the Yrotation for an object facing another object.
Reply
#4

Not possible I believe
Because the Y rotation can have ANY value independent from the X and Z rotation or the coordinated of the other object (Z axis needed here anyway)
Reply
#5

If you want it FACING another object, than it can't have any value, it does depend from x and z axis.
Reply
#6

It's the Z angle which needs working out, you need to work it out with some special formular which gets tangent, sin thing shit. Didn't really understand it, after hours of indentating + coding + testing. ********* and Me got there in the end.
Reply
#7

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
It's the Z angle which needs working out, you need to work it out with some special formular which gets tangent, sin thing shit. Didn't really understand it, after hours of indentating + coding + testing. ********* and Me got there in the end.
Same story here, but Z finding was MUCH easier.

I've changed the Y axis to Z, so that it makes things clear.
Yes, I can't find any info about calculating.
This worked out for Z:
pawn Код:
Angle[0] = clampex(270.0 - atan2( Coo[3]-Coo[0],Coo[4]-Coo[1]));
i guess you understand what clampex does.
And i tried the same for Y:
pawn Код:
Angle[4]=clampex(90.0 - atan2( Coo[3]-Coo[0],Coo[5]-Coo[2]));
Well that didn't work out the same as Z.
Coo[0] and Coo[3] is X,
Coo[1] and Coo[4] is Y,
Coo[2] and Coo[5] is Z.

If you're wondering why im i substracting atan from 90, it's because its the zero rotation value.
Reply
#8

Search for Euler Angles. It should give you enough information to create this "function".
Reply
#9

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
Search for Euler Angles. It should give you enough information to create this "function".
I did and to be honest, i didn't find anything usefull for this. And I don't want to read everything :S

EDIT:
Thanks for the help guys, this did the trick:
pawn Код:
Angle[4]=(92.5-(atan2( Coo[3]/Coo[0],Coo[5]-Coo[2])-120.0)/2);
Reply
#10

Quote:
Originally Posted by wups
Посмотреть сообщение
I did and to be honest, i didn't find anything usefull for this. And I don't want to read everything :S

EDIT:
Thanks for the help guys, this did the trick:
pawn Код:
Angle[4]=(92.5-(atan2( Coo[3]/Coo[0],Coo[5]-Coo[2])-120.0)/2);
Can you show us a picture of your final thing please? Unsure what it was suppose to look like.

#Kyle
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)