For convenience, let's first reproduce here the image given in the answer of ViewMatrix from a Graphics3D:
Where the BC segment is horizontal.
If the BC segment is supposed to be horizontal, then ViewVertical
(refer to the image) must be orthogonal to BC.
v1 = Normalize[c - b];
v2 = Normalize[(a - b) - Projection[a - b, c - b]];
v1
and v2
are orthogonal to each other. v1
is BC, horizontal by definition, and therefore v2
is the view vertical.
We can also compute
v3 = Cross[v1, v2];
so that we have a complete, orthonormal, basis for the 3D space.
a = {2, 5, 9};
b = {3, -3, 2};
c = {5, -4, -6};
d = {-1, 7, 8};
gr = Graphics3D[{
Text["A", a + .3],
Text["B", b + .3],
Text["C", c - .3],
Text["D", d + .3],
Line[{a, b, c}],
Blue, PointSize[.02],
Point[{a, b, c}],
Red, Point[d],
Black, Opacity[0.2], InfinitePlane[{a, b, c}],
Red, Thick, Opacity[1],
InfiniteLine[{b, b + v1}],
InfiniteLine[{b, b + v2}],
InfiniteLine[{b, b + v3}]
}, PlotRange -> 10]
How can I set the viewpoint so that I have a view perpendicular with
regard to plane formed by these three points ABC selected
Again referring to the image, we see that the line between the view center and the view point must be perpendicular to the plane spanned by v1
and v2
. By default the ViewCenter
is in the middle of the plot range as in the image. For simplicity we choose a plot range that runs between -10 and 10 in all three directions, that way the view center is at (0,0,0). This means that the view point must lie along v3
. Testing this:
Show[gr, ViewPoint -> 10 v3, ViewVertical -> v2, Boxed -> False]
We see that this worked out well. The segment BC is horizontal, and only two axes are visible which means that we are looking into the plane at a perpendicular angle.
And what is the distance between the point D to the plane.
The distance is the orthogonal projection of the point onto the plane:
d.v3 // N
(* Out: 0.354459 *)