Most likely something like this, not tested though. I assume you don't just have simple 2 node lines. Then you could just retrieve the start and end node of each line, create 2 Vector3D and of you go.
In case of general linestrings, which may contain arcs/curves, you need to convert them to polysegs and intersect those. Compute the station on each polyseg and then use .FindPointFromStation since only that one delivers us the correct segment orientation at the specified station location in form of the perpendicular vector .
from Trimble.Vce.Geometry import Intersections
polyseg1 = l1.ComputePolySeg()
polyseg1 = polyseg1.ToWorld()
polyseg2 = l2.ComputePolySeg()
polyseg2 = polyseg2.ToWorld()
intersections = Intersections()
if polyseg1.Intersect(polyseg2, True, intersections): # True stands for ignore Z when testing
for i in intersections:
outPointOnCL = clr.StrongBox[Point3D]()
station = clr.StrongBox[float]()
polyseg1.FindPointFromPoint(i.Point, outPointOnCL, station)
sta1 = station.Value
polyseg2.FindPointFromPoint(i.Point, outPointOnCL, station)
sta2 = station.Value
outSegment1 = clr.StrongBox[Segment]()
outSegment2 = clr.StrongBox[Segment]()
out_t1 = clr.StrongBox[float]()
out_t2 = clr.StrongBox[float]()
outPointOnCL1 = clr.StrongBox[Point3D]()
outPointOnCL2 = clr.StrongBox[Point3D]()
perpVector3D1 = clr.StrongBox[Vector3D]() # Vector containing the normalized line parameters for a line perpendicular
perpVector3D2 = clr.StrongBox[Vector3D]() # and to the right of the PointOnCL on the polyseg
outdeflectionAngle1 = clr.StrongBox[float]()
outdeflectionAngle2 = clr.StrongBox[float]()
polyseg1.FindPointFromStation(sta1, outSegment1, out_t1, outPointOnCL1, perpVector3D1, outdeflectionAngle1) # compute point and vector on line 1
polyseg2.FindPointFromStation(sta2, outSegment2, out_t2, outPointOnCL2, perpVector3D2, outdeflectionAngle2) # compute point and vector on line 2
angle = perpVector3D1.Value.Azimuth - perpVector3D1.Value.Azimuth
intersections.Clear() # in case you run this in a loop the intersections must be cleared
------------------------------
Ronny Schneider
------------------------------
Original Message:
Sent: 02-26-2023 11:07
From: Morteza Kiani
Subject: Measuring the angle between two Trimble.Vce.Alignment.Linestring.Linestring type features
Hello Trimble SDK community,
I'm wondering what is the easiest method to measure the angle between two Trimble.Vce.Alignment.Linestring.Linestring instances?
Thanks,
------------------------------
Morteza Kiani
------------------------------