Is there other solution to get bisector plane between two planes?
Currently I get it by intersecting two planes and getting intersecting line.
Then I move them and intersect again.
From those two lines I make a plane. Is there a mathematical definition of such plane or it is only possible to get it thought intersections?
public static Plane BisectorPlane(Plane a, Plane b)
Rhino.Geometry.Intersect.Intersection.PlanePlane(a, b, out Line lnA);
Rhino.Geometry.Intersect.Intersection.PlanePlane(a, b, out Line lnB);
return new Plane( lnA.From,lnA.To,lnB.PointAt(0.5));
You need first intersection to get line (point on line) as origin of bisectorPlane. Normal vector you can construct as sum of vectors a.Normal + b.Normal. Actually origin point can be also calculated from a and b planes but I am not sure that it will speed up code execution significantly…
If you have two non-parallel planes a and b (non-parallel = they have different normals) their intersection will be line L. U can use vector dot product to determine angle between normals. If angle is > PI/2 then use construct bisectprPlane with normal vector bP.N = a.N + b.N. If angle is <= PI/2 then bP.N = a.N - b.N. Doing it that way you will always construct bP that “divides larger angle”…
I tried this approach, when using only one intersection and then cross product gives normal. However, I have issue that when I constructu a plane from origin and normal, plane shifts from time to time, because before it was made from two x and y axis and origin. Is there a way to get x and y axis with this approach instead of normal?
For parallel planes I check their normal angles and then output average plane if angle is 0 is Math.PI*0.5.
This cannot be the case. The normal of the bisector cannot be the average or sum of the two input normals. It has to point in a wildly different direction, especially if the input planes have roughly the same normal direction.
What seems to work is:
Get the intersection line.
Get the middle of the intersection line, this is the bisector plane origin.
Get the tangent of the intersection line, this is the bisector X axis.
Get the average or sum of the two plane normals, this is the bisector Y axis.
(The bisector Z axis is implied by X and Y.)
I’m still not really sure this is the correct solution, or even if it is, under what (if any) conditions it fails. But see the attached GH file for playing with this approach.
Alternatively, it may make more sense to position the bisector origin not in the middle of the bisector line, but to use the average of the closest point projections of the two input planes onto the bisector line. That way the bisector is guaranteed to lie nicely halfway in between the inputs, rather than potentially quite a long way off.
Some pure algebra and geometry:
If we have two vectors, c = (c1; c2; c3), d = (d1; d2; d3), then
algebraic definition of dot product is: cd = c1d1 + c2d2 + c3d3.
geometric definition of dot product in Euclidean space is: c*d = c.Length * d.Length * cos(Theta) where Theta is angle between c and d
If c and d are orthogonal (Theta = PI/2) then:
3) c*d = 0 because cos(Theta)=0.
So if we have unit vectors:
4) a.Normal = (a1, a2, a3)
5) b.Normal = (b1, b2, b3)
and if we define c and d as :
6) c= a.Normal + b.Normal = (a1+b1, a2+b2, a3+b3)
7) d= a.Normal - b.Normal = (a1-b1, a2-b2, a3-b3)
then c and d are orthogonal.
It is easy to prove this by calculating cd by using rule 1). We will get cd=0, this implies that cos(Theta)=0 which implies that vectors c and d are orthogonal.
And c and d are normals of our two bisectionPlanes.
If you do not have specific need for using x-plane-axis and y-plane-axis for your bisection planes you should stick with origin point and normal vector while consturcting plane becasue in this case you work only with two 3d values.
But if you need it then:
9) X-axis of both bisector planes can be VECTOR CROSS PROCDUCT of a and b normals = a.Normal x b.Normal
10) Y-axis of one bisector plane is normal axis of another bisector plane, for plane cY-axis = d.Normal and vice versa
11) Z-axis are normals
Or maybe you will have to swittch X and Y axis to fulfill right-hand-rule of X-Y-Z orienatation.
Anyway, you have to choose/define which bisector plane you want to use - set some convention rule that you will follow all the way in your solution…