Jump to content


Photo

[Xpresso] - 2 point positions to matrix rotations


  • Please log in to reply
5 replies to this topic

#1 blackandwhite

blackandwhite

    Newbie

  • Members
  • 20 posts

Posted 23 May 2012 - 12:19 AM

how to setup in Xpresso so that I can input 2 point positions and figure out what the angle of rotation is between two points. I was looking at matrix functions to do this -

http://en.wikipedia....i/Rotate_matrix

not sure if it can be done in one node or if i need a few? I haven't seen any xpresso nodes yet which will output a rotation given 2 point positions of (x,y,z) vectors?

#2 tcastudios

tcastudios

    MoGraph Demi-god

  • Members
  • 548 posts

Posted 23 May 2012 - 12:30 AM

Use the Math Node in Vector and Subtract Mode and feed it with the two vectors.
Then into the "Vector2Matrix" Node (Under "Calculate" Nodes)

Cheers
Lennart
R14+ | OSX | xfiles Cinema4D Tools

#3 blackandwhite

blackandwhite

    Newbie

  • Members
  • 20 posts

Posted 23 May 2012 - 12:47 AM

doesn't seem to quite work. I'm trying to make a rail style orientation control.

so the setup is like this here:
http://www.base80.co..._spline_xpresso

but instead of using tangent, which does orient pretty well but it can produce a flipping problem in certain cases I'd like to use a rail curve. so the setup would use another curve and another spline node to output a second position. then I need to find the vector or how the position from curve one points to the corresponding position on curve two.

here is my file setup
www.paraportable.net/files/AlightToSpline_Xpresso_RAIL.rar

basically the output of the new matrix the one defined by the rail would go into the matrix2HPB and then that would pipe to the object rotation.

Edited by blackandwhite, 23 May 2012 - 12:52 AM.


#4 tcastudios

tcastudios

    MoGraph Demi-god

  • Members
  • 548 posts

Posted 23 May 2012 - 01:05 AM

It works just fine for your initial Q, now you've changed your Q and I'm off to bed.
The angle (direction) is: Position Vector1 minus Position Vector2.

Cheers
Lennart
R14+ | OSX | xfiles Cinema4D Tools

#5 tcastudios

tcastudios

    MoGraph Demi-god

  • Members
  • 548 posts

Posted 23 May 2012 - 11:22 AM

So you want to make your own AlignToSpline Tag with a rail spline function, right?
Anything ToHPB will null the B and flip it.
You need to use the Cross Product of your tangent and the rail spline position
to determine the third axis.
I suck at Xpresso so I have no example to give, but check the Cross Product Node
and how to normalize the result.

Cheers
Lennart
R14+ | OSX | xfiles Cinema4D Tools

#6 blackandwhite

blackandwhite

    Newbie

  • Members
  • 20 posts

Posted 23 May 2012 - 03:22 PM

Thanks!

I feel like I'm close to getting the proper output now. not quite what I need. from what I can tell I did what you said.

cross product of spline 1 tangent with position of rail spline 2 then universal node set to normal to normalize the result of that.

I hooked up the output from that into the rotation and it seems pretty close but its not identical to the way that align to spline tag works with rail input.

I have an xpresso setup here if anyone can dig in and figure out what the solution would be.

www.paraportable.net/files/AlightToSpline_Xpresso_RAIL_V3.rar




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users