Notifications
Clear all

[Closed] Minds gone blank!! Simple Math question

how can I calculate the position of a point 10 units away from an object on its x axis

12 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

tm = obj.transform – obj’s transform in world coord sys
pretranslate tm [10,0,0]
tm.pos – pos in world coord sys after translation on 10 units in local X

Thanks Denis. I just found that in the documentation actually but I’m more interested in how its calculated without functions. If you know how could you spare some time to explain.

thePos = yourObj.pos

newPos = [thePos[1] + 10 , thePos[2] ,thePos[3]]

–or maybe

newPos = yourObj.pos + [10,0,0]

 JHN

That does only work when the box is not rotated, this doesn’t define a context in which you translate the object. You could use

in coordsys local move $ [10,0,0]

Otherwise you would be building a vector from the direction the x axis is pointingand multiply that by the length of the translation, and reapply that back to the position, or something like that.

-Johan

 PEN

Or…

theObject.transform=(transMatrix [10,0,0])*theReferenceObject.transform

cheers but I was creating bones based on the direction of another bone so needed the End Position. Denis’s method worked fine for me but its bugging me that I don’t understand how its calculated.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

what do try to understand?

obj.transform is object’s transformation matrix (3×4) in world system of coordinates.
pretranslate <tm> <point3> means translate matrix in its local systems on point3

to get new position of our matrix in world coords we have to ask for fourth row of matrix (position) tm.row4 (tm[4], tm.pos, tm.position, tm.translation, tm.translationpart :))

I think your misunderstanding me. I understand what’s going on in Max but I would like to know how to calculate it on paper or how the preTranslate function works internally.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

OK. You asked for it!

How to transform a point from one system coord to another:

You have two coord systems e1,e2,e3 and b1,b2,b3
because these vectors are basis vectors we can define:

b1 = b1.xe1 + b1.ye2 + b1.ze3
b2 = b2.x
e1 + b2.ye2 + b2.ze3
b3 = b3.xe1 + b3.ye2 + b3.z*e3
or in matix form
[b1 b2 b3]^T = B * [e1 e2 e3]^T

where B is matrix b{1,2,3}.{x,y,z}
and ^T is operation of transposition

take any vector v [color=white][/color]
vector decomposition in basis [b1 b2 b3] is
v = v1.x * b1 + v1.y * b2 + v1.z * b3 = [v1.x v1.y v2.z] * [b1 b2 b3]^T

now you want to get coords of the vector v in [b1 b2 b3]
make basis b decomposition using e

v = [v1.x v1.y v1.z] * B * [e1 e2 e3]^T

[v1.x v1.y v1.z] * B is coordinates of vector v in basis [b1 b2 b3]
or in matrix form
B^T * [v1.x v1.y v1.z]^T

[color=white]Do you feel better now? :)[/color]

hahahah not so simple math then. Thanks for writing that up. I appreciate your time.

I hope you don’t mind but I would like to bug you with another question. Where can I learn such things? I have 3D Math Primer for Graphics and Games Development but I doesn’t explain how to do that.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

Thanks. Ill stop bugging you now