Help with angles / relative position
#2

if your relative objects' position is on the same plane (on the x/y axis), then you might be able to use a sinus/cosinus transformation - it converts an input coordinate+angle+radius to a target position on the same height (z axis, due the formula transforms x/y coordinates only). handy for roads bends left/right.
if you need an object positioned AND rotated on all 3 axis, then you have to read about quaternions, they are, as the name implicates, a 4-dimensional representation of rotations. you might have read about the attached objects, theyre using a rotation-matrix (most prolly derivated by using quaternions, iam not sure about this). to attach an object to its parent, you "only" need its relative position from the origin/parent.
warning: to obtain a relative objects' position/rotation offset, its clever to place the parent at 0-0-0 rotation, find the children-object (attached object) position and rotation (x/y only), and then to subtract each parameter. the result can be used to attach it with the upward-mentioned sin/cos functions, as long you are rotating the objects on the z axis only. a later rotation on the x or y axis will be influenced by the so-called "gimbal lock" - good luck at finding a better solution, iam (again) actually trying to crack those fucking quaternions, with few success btw ><
edit: oops, i forgot to paste the sin/cos in action, here it is, derivated from my object editor:
pawn Код:
ObjectX[o][0]=floatadd(BasisPosX,Radius*floatsin(Angle,degrees));
ObjectY[o][0]=floatadd(BasisPosY,Radius*floatcos(Angle,degrees));
Reply


Messages In This Thread
Help with angles / relative position - by Siralos - 03.09.2012, 07:00
Re: Help with angles / relative position - by Babul - 03.09.2012, 07:15
Respuesta: Help with angles / relative position - by Siralos - 03.09.2012, 07:26
Re: Help with angles / relative position - by Babul - 03.09.2012, 07:53
Re: Help with angles / relative position - by MP2 - 03.09.2012, 09:01

Forum Jump:


Users browsing this thread: 2 Guest(s)