Hi!
I have two lines to compare direction.( to check two line go same direction or not.)
I made two Ray3D objects from the lines like below.
Dim oRay_Cell As Ray3dDim oRay_Line As Ray3d
oRay_Cell = Ray3dFromPoint3dStartEnd(oLineFromCell.startPoint, oLineFromCell.EndPoint)oRay_Line = Ray3dFromPoint3dStartEnd(oLineFromLine.startPoint, oLineFromLine.EndPoint)
But I don't know how to compare the direction.
oRay_Cell.Direction ,,,,, oRay_Line.Direction
Unknown said:I have two lines to compare direction.( to check two line go same direction or not.)
You're asking if two lines are parallel.
Unknown said:I don't know how to compare the direction
How about Ray3dRay3dClosestApproach? From VBA help...
Compute the closest approach of two lines in 3d, considering both lines unbounded. Returns true if the lines intersect, false if parallel or coincident
Regards, Jon Summers LA Solutions
Thank you, Jon.
User will put the arrow-mark on the line, so Arrow-mark and line are parallel.
Like below, there are two cases to check.
case 1 : Same direction arrow-mark with line (StartPoint -- EndPoint)
case 2 : Opposite direction arrow-mark with line(EndPoint -- StartPoint)
I like to know the condition of the arrow-mark placement by user
How can I know case1 or case 2 ?
Unknown said:How can I know case1 or case 2 ?
Compute angles of the line and the arrow: In case 1 the angles will be the same, in case 2 they will be different by 180 degress (or PI/2).
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Unknown said:How can I know case1 or case 2?
You want to determine whether two vectors are parallel or anti-parallel. Compute the cross product.
With VBA, you need to use Vector3D objects rather than Ray3D objects so you can use Vector3dCrossProduct.
Answer Verified By: Unknown
I got an answer from www.la-solutions.co.uk/.../MVBA-Rotation.htm
Dim rotationX As Double
Dim rotationY As Double
Dim rotationZ As Double
Dim scaleFactor As Double
If (Matrix3dIsXRotationYRotationZRotationScale(rotationMatrix, rotationX, rotationY, rotationZ, scaleFactor)) Then
Debug.Print "Cell rotation XYZ " & _
CStr(Round(Degrees(rotationX), 0)) & "#" & _
CStr(Round(Degrees(rotationY), 0)) & "#" & _
CStr(Round(Degrees(rotationZ), 0))
End If
Answer Verified By: seokjew hong
Hi,
One issue I had (using a different command) was tolerance. I had to say, if the difference in angle is less than my tolerance, then it is parallel. With out that, I had "rounding errors" which produced an insignificant difference that would tell me that the lines were not parallel.
--Robert
Unknown said:One issue I had (using a different command) was tolerance. I had to say, if the difference in angle is less than my tolerance, then it is parallel
That's an argument in favour of using the cross-product of two vectors. First, it's simpler than extracting and comparing three sets of angles; second, it's numerically concise: if the cross-product is zero then the vectors are parallel.
The cross-product can also inform you if two unit vectors are perpendicular. You can see why the cross-product, and its companion the dot-product, are useful and why they are included in the VBA library. See...