Blanks

09-12-2009, 07:40 PM

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

View Full Version : Minds gone blank!! Simple Math question

Blanks 09-12-2009, 07:40 PM how can I calculate the position of a point 10 units away from an object on its x axis |

denisT

09-12-2009, 07:48 PM

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

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

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

Blanks

09-12-2009, 07:56 PM

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.

DanLane

09-14-2009, 09:18 PM

thePos = yourObj.pos

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

--or maybe

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

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

--or maybe

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

JHN

09-14-2009, 11:37 PM

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

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

09-15-2009, 01:55 AM

Or...

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

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

Blanks

09-15-2009, 01:54 PM

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.

denisT

09-15-2009, 05:45 PM

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.

what do try to understand?

obj.transform is object's transformation matrix (3x4) 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 :))

what do try to understand?

obj.transform is object's transformation matrix (3x4) 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 :))

Blanks

09-15-2009, 05:54 PM

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.

denisT

09-15-2009, 06:21 PM

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.

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.x*e1 + b1.y*e2 + b1.z*e3

b2 = b2.x*e1 + b2.y*e2 + b2.z*e3

b3 = b3.x*e1 + b3.y*e2 + 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

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

Do you feel better now? :)

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.x*e1 + b1.y*e2 + b1.z*e3

b2 = b2.x*e1 + b2.y*e2 + b2.z*e3

b3 = b3.x*e1 + b3.y*e2 + 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

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

Do you feel better now? :)

Blanks

09-15-2009, 06:40 PM

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.

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.

denisT

09-15-2009, 06:53 PM

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.

it's a pretty good source: http://www.numbertheory.org/book/

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.

it's a pretty good source: http://www.numbertheory.org/book/

Blanks

09-15-2009, 06:58 PM

Thanks. Ill stop bugging you now ;)

CGTalk Moderation

09-15-2009, 06:58 PM

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.

vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.