Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operations on moved segment still use its original position #20

Open
dgDSA opened this issue Dec 22, 2023 · 1 comment
Open

Operations on moved segment still use its original position #20

dgDSA opened this issue Dec 22, 2023 · 1 comment

Comments

@dgDSA
Copy link

dgDSA commented Dec 22, 2023

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))

@hmycroft
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants