Anubis

03 March 2008, 03:39 PM

Has anyone ever done something like this (http://www.kwon3d.com/theory/jkinem/rotmat.html) in maxscript?

Does max already have this fucntionality?

Does max already have this fucntionality?

View Full Version : Deriving a pivot point from a fixed body moving through space

Anubis 03 March 2008, 03:39 PM Has anyone ever done something like this (http://www.kwon3d.com/theory/jkinem/rotmat.html) in maxscript? Does max already have this fucntionality? |

eek

03 March 2008, 06:16 PM

I dont think this is too hard overall but least squared is something i never can figure out.

1. store the direction of a bunch of markers (least square)

2. check where they closest intersect

Isnt this the same aproach as spherical skinning where you need to find Rc - the center of the rotational transform.

You guys at crytek have implemented spherical skinning so there tech guys there should be able to help you. :)

1. store the direction of a bunch of markers (least square)

2. check where they closest intersect

Isnt this the same aproach as spherical skinning where you need to find Rc - the center of the rotational transform.

You guys at crytek have implemented spherical skinning so there tech guys there should be able to help you. :)

Anubis

03 March 2008, 06:33 PM

Heh, yeah, I am sure the guys in R&D could help, but I don't have the best math skills, and I don't feel like bugging them.

Also mainly because I am doing stuff in Max that I should be doing in MBuilder. (Solving the rot/trans of the the skull from a headband with mocap markers on it) I just don't know MBuilder. I solved the head rot pretty easily, but I want to solve the neck, and to do this I need to solve the head pos. :)

You ever dealt with raw mocap markers in max? It's really fun, there are so many little fast tools that need to be written to deal with mocap because it's pretty useless in it's raw state.

Also mainly because I am doing stuff in Max that I should be doing in MBuilder. (Solving the rot/trans of the the skull from a headband with mocap markers on it) I just don't know MBuilder. I solved the head rot pretty easily, but I want to solve the neck, and to do this I need to solve the head pos. :)

You ever dealt with raw mocap markers in max? It's really fun, there are so many little fast tools that need to be written to deal with mocap because it's pretty useless in it's raw state.

eek

03 March 2008, 07:10 PM

Im thinking of arc Tangent methods.. This is a little tricky.

Anubis

03 March 2008, 05:01 PM

Yeah, I think that's how I originally did it to solve in 1 axis rotation (2d) but as soon as I took that to 3d I realized it wouldn't work. In 2d the perpendicular line through the midpoint of a line drawn between a point's location in frame x and frame y would go through the pivot, comparing say, the motion from frame 1 and 2 vs 2 and 3 would give me two lines that intersect at the pivot.

You ever done something liek this in maxscript? (ray/ray intersection):

Two parametric rays:

r1*t1=p1+(t1*d1)

r2*t2=p2+(t2*d2)

Solve for t1 and t2 to find the point of intersection.

r1(t1)=r2(t2)

p1+t1(d1)=p2+t2(d2)

t1=((p2-p1) cross d1) dot (d1 cross d2)/(magnitude(d1 cross d2)*magnitude(d1 cross d2))

If parallel: cross of d1 and d2 is the zero vector

If skew (crossing but not on same plane): p1(t1) and p2(t2) are the points that are closest. Examine the distance between p1(t1) and p2(t2) to determine if they actually intersect in your world. This means you must use a fudge factor due to floating point imprecision.

You ever done something liek this in maxscript? (ray/ray intersection):

Two parametric rays:

r1*t1=p1+(t1*d1)

r2*t2=p2+(t2*d2)

Solve for t1 and t2 to find the point of intersection.

r1(t1)=r2(t2)

p1+t1(d1)=p2+t2(d2)

t1=((p2-p1) cross d1) dot (d1 cross d2)/(magnitude(d1 cross d2)*magnitude(d1 cross d2))

If parallel: cross of d1 and d2 is the zero vector

If skew (crossing but not on same plane): p1(t1) and p2(t2) are the points that are closest. Examine the distance between p1(t1) and p2(t2) to determine if they actually intersect in your world. This means you must use a fudge factor due to floating point imprecision.

eek

03 March 2008, 06:13 PM

I think i found a cleaner way - i was infact dreaming of the math this morning sadly.

If you have a point a moving through a space you get:

A direction 90 degree perpendicular to the tangent line at the start i.e f [0,1]

The same for the end of the motion i.e f[99,100]

The interesection point is the rotation center

Get this in each axis and average the result.

https://nrich.maths.org/discus/messages/67613/68174.gif

http://nrich.maths.org/discus/messages/67613/68169.html?1137605065

I'll think some more.

If you have a point a moving through a space you get:

A direction 90 degree perpendicular to the tangent line at the start i.e f [0,1]

The same for the end of the motion i.e f[99,100]

The interesection point is the rotation center

Get this in each axis and average the result.

https://nrich.maths.org/discus/messages/67613/68174.gif

http://nrich.maths.org/discus/messages/67613/68169.html?1137605065

I'll think some more.

eek

03 March 2008, 10:39 PM

(

local startFrame = 0

local endFrame = 10

local s0 = [0,0,0]

local s1 = [0,0,0]

local e0 = [0,0,0]

local e1 = [0,0,0]

local rotCenters = #()

local n1 = [0,0,0]

local n2 = [0,0,0]

local sum = [0,0,0]

for i = 1 to selection.count do

(

slidertime = startFrame; s0 = selection[i].pos

slidertime = (startFrame + 1); s1 = selection[i].pos

slidertime = endFrame; e0 = selection[i].pos

slidertime = (endFrame - 1); e1 = selection[i].pos

local td = 0.1 -- this is the accuracy

for i = 1 to 100 by 0.01 do

(

if (distance ((1-i)*s0 + s1*i) ((1-i)*e0 + e1*i)) < td do

(

n1 = ((1-0.5) * (1-i)*s0 + s1*i) + 0.5 * ((1-i)*e0 + e1*i)) -- gets the pre-reflected center.

n2 = ((1 - 0.5)*s0 + e0 * 0.5) -- gets the center of the chord of the arc.

append rotCenters ( (1 - -1) * n2 + -1 * n1) -- this is the reflection *important!

exit -- is this needed?, yes i think so.

)

)

) -- end of selection loop

for n = 1 to rotCenters.count do

(

sum += rotCenters[n]

)

local rotCenterPoint = point()

rotCenterPoint.pos = (sum/rotCenters.count)

)

Ok, this might work - i dont have max here so I dont know. To setup, select a bunch of objects with an animation going from 0 to 10 with a rotation center your trying to calculate. This is dirty btw and could be done cleaner with a cross product.

local startFrame = 0

local endFrame = 10

local s0 = [0,0,0]

local s1 = [0,0,0]

local e0 = [0,0,0]

local e1 = [0,0,0]

local rotCenters = #()

local n1 = [0,0,0]

local n2 = [0,0,0]

local sum = [0,0,0]

for i = 1 to selection.count do

(

slidertime = startFrame; s0 = selection[i].pos

slidertime = (startFrame + 1); s1 = selection[i].pos

slidertime = endFrame; e0 = selection[i].pos

slidertime = (endFrame - 1); e1 = selection[i].pos

local td = 0.1 -- this is the accuracy

for i = 1 to 100 by 0.01 do

(

if (distance ((1-i)*s0 + s1*i) ((1-i)*e0 + e1*i)) < td do

(

n1 = ((1-0.5) * (1-i)*s0 + s1*i) + 0.5 * ((1-i)*e0 + e1*i)) -- gets the pre-reflected center.

n2 = ((1 - 0.5)*s0 + e0 * 0.5) -- gets the center of the chord of the arc.

append rotCenters ( (1 - -1) * n2 + -1 * n1) -- this is the reflection *important!

exit -- is this needed?, yes i think so.

)

)

) -- end of selection loop

for n = 1 to rotCenters.count do

(

sum += rotCenters[n]

)

local rotCenterPoint = point()

rotCenterPoint.pos = (sum/rotCenters.count)

)

Ok, this might work - i dont have max here so I dont know. To setup, select a bunch of objects with an animation going from 0 to 10 with a rotation center your trying to calculate. This is dirty btw and could be done cleaner with a cross product.

CGTalk Moderation

03 March 2008, 10:39 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.