In my code, I use the viktor.Geometry.point_is_on_bounded_line()
I have a point, and loop through some lines to see if the point is on the line, simple.
Noiw, the function kept returning False eventhough I knew the point was on the line.
Snippet of my code:
# Loop through lines in wireframe and check if point is on line
for staaf in wireframe.Staven:
p1: Point = wireframe.Knopen[staaf.Knoop1]
p2: Point = wireframe.Knopen[staaf.Knoop2]
line = Line(p1, p2)
print(f"if point: {checkpoint}")
print(f"is on line from start: {line.start_point}")
print(f"is on line to end: {line.end_point}")
print(f"result is: {point_is_on_bounded_line(checkpoint, line, False)}")
if point_is_on_bounded_line(checkpoint, line, False):
print(f"FOUND THE LINE!")
The loop that should return true prints this info:
if point: Point(1.153e+01, 1.868e+01, 0.000e+00)
is on line from start: Point(1.153e+01, 1.935e+01, 0.000e+00)
is on line to end: Point(1.153e+01, 1.852e+01, 0.000e+00)
result is: False
Note that it is a vertical line with x = 1.153e+01
The Y of the line sits between 1.852e+01 and 1.935e+01 so the value of the point 1.868e+01 falls nicely between the ends.
I also used the function for these values, testing them hardcoded, and that does return true:
print(f"literal input: {point_is_on_bounded_line(Point(11.53, 18.85), Line(Point(11.53, 19.35), Point(11.53, 18.52)))}")
So, either it is linked to this 3d Space error (Viktor.geometry.point_on_bounded_line not correct in 3D space, but this bug is old and reported to be fixed). And the z-dimensions are 0. Or it is due to the mathematical notation. But I’m not sure if that is just how the Point prints its float, or that that it actually supports a different notation.
Using SDK 14.2, Connector v5.21.0 and CLI v0.30.6