Geometry3D
Geometry3D copied to clipboard
Operations on moved segment still use its original position
After moving a Segment by (0, 0, -1), the "in" and "intersection" operations still take the original position into account.
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
Geometry3D.version '0.2.4'
s = Segment(Point(0, 0, 1), Point(2, 0, 1)) s.move(-z_unit_vector()) Segment(Point(0, 0, 0), Point(2, 0, 0)) s Segment(Point(0, 0, 0), Point(2, 0, 0)) s2 = Segment(Point(0, 0, 0), Point(2, 0, 0)) s == s2 True Point(1, 0, 0) in s2 True Point(1, 0, 0) in s False # Should return True Point(1, 0, 1) in s True # Should return False ground = Plane(origin(), x_unit_vector(), y_unit_vector()) print(intersection(s2, ground)) Segment(Point(0, 0, 0), Point(2, 0, 0)) print(intersection(s, ground)) None # Should return the segment
This may be caused by a failure to move the "line" attribute accordingly:
s.line Line(sv=Vector(0, 0, 1),dv=Vector(2, 0, 0)) s2.line Line(sv=Vector(0, 0, 0),dv=Vector(2, 0, 0))
Doing Advent of Code? :)
I had the same problem yesterday trying to figure out the bug in my code as it wasn't working. It does indeed turn out that the function move on line 85 of segment.py doesn't move self.line, which in turn is used by intersection! I just added a self.line.move(v) and now everything works! Spent hours on that yesterday!