Subject:
|
Re: Finding a rotation matrix for a triangle
|
Newsgroups:
|
lugnet.cad
|
Date:
|
Mon, 5 Dec 2005 14:11:53 GMT
|
Viewed:
|
1789 times
|
| |
| |
> {The angle of the plane defined by the three points}: I need to slap a
> primitive directly onto the triange with the correct angle.
Now I think I see what you mean. You want to know how to rotate the primitive so
that it lines up with one of the edge lines of the triangle.
> Now, if I should only slap this edge-primitive onto some rect-primitive, I
> should be able to copy the angle directly. But since triangles aren't defined
> by rotation matrix, I thought that the triangle would need to be converted
> into something that [is] (like a plane)
This isn't the best way to go (I'll explain at the end of the post).
> > If you are thinking of a specific way of obtaining the angle from the
> > triangle, please let me know and I can work out the formla for you.
>
> It would be really great to have a formula where you can enter the three
> coordinates of the triangle, and have an output in the form of the numbers
> that need to be entered into the xyz+angle-formula in MLCAD.
>
> -To put my edge primitive at the excact same angle as the triangle.
OK. The problem here is that what you want to do cannot be done by the way you
suggest doing it. There is no formula as you describe it since it has no
meaning. Also you need BOTH the rotation vector AND a second vector for
positioning and the forumla would have to find both of these.
> I hope that made sense...
>
> > One thing that can be done is to find an orthogonal basis set which spans
> > the plane which might be useful. If this is of interest to you I can write
> > some code for it.
>
> I'm not sure what you mean by this: language barriers seem to be a big
> problem in this discussion - but I'm really grateful that you wish to help
> me...
>
> Cheers NB
Yes. My suggestion for future discussion is to state the original problem rather
than trying to half work through it. In this case what you want to know is not
really what you're asking and what you are asking is actually impossible.
Now the solution to moving your primitive so that it lies on the edge of a
triangles and points perpendicular to the triangle can be solved quite easily
(which can then give you the XYZ+angle and displacement vector but you don't
need that).
I will assume that your primitive requires no scaling and has its origin at the
left side and is originally in the XY plane.
What you need to do first is to calculate your basis set (like xyz but in a
different frame of reference, much like how when you rotate a map NS/EW are
moved).
In vector form, you have the triangle defined by P1, P2, P3. I will assume that
these are definied in a clockwise direction.
set d1=norm(P2-P1)
-- norm means to divide the vector by its length to make a unit vector
set d2=norm(cross(P2-P1,P3-P2))
-- cross means to take the vector cross product
set d3=cross(d1,d2)
your transformation matrix is then
M=[d1x d2x d3x d1y d2y d3y d1z d2z d3z P1x P1y P1z]
where d1x means the x component of d1 etc.
So. Your ldr command is
1 COLOUR d1x d2x d3x d1y d2y d3y d1z d2z d3z P1x P1y P1z PRIMITIVE.DAT
Now you could convert this to XYZ + angle and a displacement vector but this is
not really neccesary, nor a particularly good idea.
Does that answer your question?
Tim
|
|
Message has 1 Reply:
Message is in Reply To:
| | Re: Finding a rotation matrix for a triangle
|
| (...) The angle of the plane defined by the three points: I need to slap a primitive directly onto the triange with the correct angle. Now, if I should only slap this edge-primitive onto some rect-primitive, I should be able to copy the angle (...) (19 years ago, 5-Dec-05, to lugnet.cad, FTX)
|
13 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|