Ok guys, I'm not a great mathematician but will try to work this as accurately as I can. I hope someone can help me.
I am drawing some 3D objects and I am having trouble drawing an Octahedron. I need to dynamically calculate all points of each triangle in the Octahedron based on two known factors, the topmost XYZ point of the shape and the bottommost XYZ point of the shape.
What I am looking is to create Octahedron in 3D space based on just two parameters:
- Point 1 – The top most point of the Octahedron (XYZ point in 3D space)
- Point 2 – The bottom most point of the Octahedron (XYZ point in 3D space)
See below
As you can see from the picture above, I also need the shape to be "skewed", so that the top half (side closed to point 1), takes up 85% of the total height between point 1 and 2 (so the shape is not symmetrical).
I can easily calculate this taking the length of the vector result from (point1 – point2).
I also need the shape to respect if Point 1 is passed in below point 2 (when point 2's Y co-ordinate is greater than point 1's, see below):
How do I calculate this if all that is known is the two points?
Thanks in advance!
Best Answer
Let $P_1$ be the topmost point, $P_2$ the bottom-most point. Let $v,w$ be a unit vectors such that ${P_1P_2},v,w$ are orthogonal. Let $r>0$ be arbitrary. (There is arbitrariness in the choice of $v,w$ and $r$, which shows thatyour shape is underspecified; I assume you want to let $r$ a constant multiple of $|P_1P_2|$). Then the points $P_1$, $P_2$, $0.85P_1+0.15P_2+rv$, $0.85P_1+0.15P_2+rw$, $0.85P_1+0.15P_2-rv$, $0.85P_1+0.15P_2-rw$ make up the vertices of a skew octahedron as you describe.