Notifications
Clear all

[Closed] Using LengthTangent?

Okay, I promise this time I’m stuck, without even an idea on how to proceed next.

I have a tangent to a shape (via lengthTangent) which is a Point3. But how to use this in any way to set the direction of an object I have no clue. I can’t convert it to a EulerAngle (fails), it’s obviously not a quat so I can’t use it to set rotation, I just don’t know what good it is.

Anyone have a clue?

2 Replies

The vector can be used to set the .dir (direction) property of an object:

$Box01.dir = [b]theVector[/b]

Or you could use it to build a matrix:


wUp = [0,0,1] -- up vector. can be any normalized point3
rVec = normalize (cross wUp [b]theVector[/b])
uVec = normalize (cross rVec [b]theVector[/b])

theMatrix = matrix3 rVec uVec [b]theVector[/b] [0,0,0]

The last part of the matrix3 is the translation (position), which in this case is set to the world center.

The matrix can then be applied to an object like so:

$Box01.transform = [b]theMatrix[/b]

Hope this helps,
Martijn

Well, I do appreciate the response, but what you gave me doesn’t work.

If I try and set the .DIR to the tangent it moves it perpendicular to the line. In fact, my understanding is that .DIR is the Z direction, so this is correct (IOW, that’s what should happen). What I need to do is set it not to the Z direction but to the XY directions.

What DOES work is to do this:

mytransform = matrix3 up tangent right position
Move_Object.transform = mytransform

where tangent is the second max3 position, not the third. I agree with you it should be the third according to the docs, but it works this way and will not work any other way. Maybe there is something wrong with my system (although it’s a base Max in every way) but that’s what happens for me.

I’d love to understand why what you’ve written doesn’t work for me and the above does because my next trick is to try and derive the difference between the tangent of the object to one line and apply it to a second line. That is to say, there is an object that faces a certain way relative to line01. I’d like to move it to the same relative position on line02 (got this much) and rotate it the same way as the rotation is to line01.

I’m guessing what I need to do is get the tangent from the first line and (subtract?) it from the object tangent and take this difference and apply it to the tangent on the second line. But without understanding why my position is on the second level of the mat3 when it should be on the third makes this kind of trial and error.