HI all,
I cannot for the love of all things unholy find a function that tells me if either:
1. Two shapes are coplanar, or 2. Two plane3d are coplanar, or 3. A function that unifies all shapes that are coplanar, regardles of all shapes in the array actually being coplanar to begin with.
See, I want to merge (union) some simple triangular shapes together. That is easy - as long as the shapes are coplanar - using GetRegionUnion. But if there is even a slight difference in copla..narity (?) it goes belly up.
Do I really need to DO MATH?
Regards,/T
Unknown said: I cannot find a function that tells me if either: 1. Two shapes are coplanar, or 2. Two plane3d are coplanar
I cannot find a function that tells me if either:
1. Two shapes are coplanar, or 2. Two plane3d are coplanar
We wrote a VBA project answering your question that is explained in this article.
Unknown said:From what I read, the essence is that we have to do math. Do I really need to do math?
No: in this case MicroStation VBA does the hard work for you. However, you need to understand the geometric 3D concepts of points, planes and normals for the solution to make sense.
Regards, Jon Summers LA Solutions
Answer Verified By: Torben
Hi Guys,
Wow! Thanks for all the nice work. I am sure that will save a few future math-questions around here! :)As stated earlier I went with this semi built-in functionality:
Function isCoplanar(a As Element, b As Element) As Boolean On Error Resume Next isCoplanar = True Dim aa(0) As Element Set aa(0) = a Dim ab(0) As Element Set ab(0) = b GetRegionUnion aa, ab, Nothing If Err.Number <> 0 Then isCoplanar = False Err.Clear End If Erase aa Erase ab End Function
System: Win7 64bit 16GB Ram - microStation V8i SS3 08.11.09.578. + PoinTools CONNECT. - Intel i7-4800MQ CPU@2.70GHz, 4 core / 8 Logic proc.
Solution no longer available. Please re-share.
Oto said:Please re-share
A plane is defined by its normal and a point on that plane. MicroStation VBA provides the Plane3d user-defined-type (UDT). The two data members of Plane3d are its Normal and Origin.
Plane3d
Normal
Origin
A MicroStation VBA ClosedElement, such as a ShapeElement or an EllipseElement, has a Normal property. It's therefore very easy to derive a Plane3d from a ClosedElement. The normal of the plane is the normal of the closed shape, and any point on that closed shape can be the origin of the plane …
ClosedElement
ShapeElement
EllipseElement
Dim oShape As ShapeElement ... get shape from somewhere Dim plane As Plane3d plane.Normal = oShape.Normal plane.Origin = oShape.Vertex (1)
Two planes may be parallel but not necessarily coplanar. They are parallel if their normals are identical. If they are not parallel then they intersect.
Two planes are coplanar if two conditions are satisfied …
VBA provides many methods that deal with 3D objects. Often, it's hard to work out those methods that will help in a given situation.
In this case, we want first to find whether two planes are coplanar. VBA method Plane3dIntersectsPlane3d tells us if two planes intersect. Therefore, the Boolean inverse of that function tells us whether two planes are parallel …
Plane3dIntersectsPlane3d
Dim plane1 As Plane3d Dim plane2 As Plane3d ... get planes from somewhere Dim intersectionRay As Ray3d Dim intersection As Boolean intersection = Plane3dIntersectsPlane3d (intersectionRay, plane1, plane2) Dim parallel As Boolean parallel = Not intersection
Expressing that test more concisely …
Dim parallel As Boolean parallel = Not Plane3dIntersectsPlane3d (intersectionRay, plane1, plane2)
We can test if a point on one plane lies on another plane using VBA method Point3dProjectToPlane3d. If we project the origin of plane 1 onto plane 2 and the result is identical, then the planes must be coplanar. Here's a function to perform that test …
Point3dProjectToPlane3d
Function TestPlanesCoplanar( _ ByRef plane0 As Plane3d, ByVal label0 As String, _ ByRef plane1 As Plane3d, ByVal label1 As String) As Boolean TestPlanesCoplanar = False Const TrueProjection As Variant = 0 Const ModelCoordinates As Boolean = False Dim projection As Point3d projection = Point3dProjectToPlane3d(plane0.Origin, plane1, TrueProjection, ModelCoordinates) If Point3dEqual(projection, plane0.Origin) Then TestPlanesCoplanar = True Debug.Print "Plane" & label0 & " is coplanar with plane" & label1 Else Debug.Print "Plane" & label0 & " is not coplanar with plane" & label1 End If End Function
Is the full project "CoPlanarShapes.zip" lost?