Math help


Math help
#1
Forgive me for such a basic question but I'm having issues and my Google-fu is failing me.

I have a line segment from P1 to P2

Assuming that the origin is P1, I can get the spherical coordinates (r, theta, phi) of line segment but I can't seem to figure out how to go from that to a rotation matrix. Any help, even in the form of a link to a explanation, would be appreciated
Reply
RE: Math help
#2
(2019-03-24, 19:06)Orion Pobursky Wrote: I have a line segment from P1 to P2

What are you trying to do?

Because you can't build a matrix from just a line segment without assuming some other stuff.
You'll need at least two vectors perpendicular to each other for this.

In LDCad's path generator I use the world Y axis to find the second but it depends on your situation.
Reply
RE: Math help
#3
(2019-03-24, 19:31)Roland Melkert Wrote: What are you trying to do?

Because you can't build a matrix from just a line segment without assuming some other stuff.
You'll need at least two vectors perpendicular to each other for this.

In LDCad's path generator I use the world Y axis to find the second but it depends on your situation.


Assume the wold axis in this case. Assume P1 is the axis origin (0,0,0) in the LDraw standard world space. I can even figure out the direction angles but for some reason I'm not grokking what to do next. it's annoying me that I'm missing something so basic.
Reply
RE: Math help
#4
(2019-03-24, 20:00)Orion Pobursky Wrote: Assume the wold axis in this case. Assume P1 is the axis origin (0,0,0) in the LDraw standard world space.

In that case P2 is your base local (y) vector.
Normalize p2

Cross p2 with world Y   (0, 1, 0)
to Get a second local vector perpendicular to p2 (your local z)
Normalize local z

Then cross p2 and the new local z to get the 3rd vector (your local x)
Normalize local x

Use the 3 local axis to construct the matrix.

There are limits though, depending on the direction of p2 things will flip 180 degrees at some point and if p2 is close to world y it will not solve.
In my path generator I choose world Y or Z as the reference bases on the biggest angle.

There might be a more elegant way of solving this but I'm no math major Smile
Reply
RE: Math help
#5
(2019-03-24, 21:20)Roland Melkert Wrote: In that case P2 is your base local (y) vector.
Normalize p2

Cross p2 with world Y   (0, 1, 0)
to Get a second local vector perpendicular to p2 (your local z)
Normalize  local z

Then cross p2 and the new local z to get the 3rd vector (your local x)
Normalize local x

Use the 3 local axis to construct the matrix.

There are limits though, depending on the direction of p2 things will flip 180 degrees at some point and if p2 is close to world y it will not solve.
In my path generator I choose world Y or Z as the reference bases on the biggest angle.

There might be a more elegant way of solving this but I'm no math major Smile

Thanks. This seems similar to what I was reading but for some reason wasn’t leaking into my brain.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)