Pyrr icon indicating copy to clipboard operation
Pyrr copied to clipboard

ray_intersect_plane yields incorrect results

Open kietdlam opened this issue 6 years ago • 4 comments
trafficstars


import pyrr
import numpy as np

p1 = np.array([0.6122449, 0.8163265, 1.562406])
p2 = np.array([0.8571429, 0.7142857, 1.976692])
p3 = np.array([0.6122449, 0.6326531, 1.250161])

plane = pyrr.plane.create_from_points(p1, p2, p3)

ray = pyrr.ray.create_from_line([np.array([1, 1, 1]), np.array([0, 1, 1])])
print(pyrr.geometric_tests.ray_intersect_plane(ray, plane))

yields : [-0.83114114 1. 1. ] expected: [0.247 1 . 1. ]

Why does ray_intersect_plane yield this wrong result?

kietdlam avatar Apr 18 '19 12:04 kietdlam

Ok

adamlwgriffiths avatar Apr 18 '19 14:04 adamlwgriffiths

Sorry closed by accident, this is still an issue.

kietdlam avatar Apr 18 '19 18:04 kietdlam

print(pyrr.plane.create_from_points(p1, p2, p3)) => [-0.77258732 -0.54724948 0.32191123 0.41679086]

The plane equation should have Ax + By + Cz + D = 0

-0.77258732*-0.83114114 + -0.54724948 + 0.32191123 + 0.41679086 = 0.8335817158943447

which is not 0.

The answer from ray_intersect_plane is not on the plane at all.

kietdlam avatar Apr 18 '19 20:04 kietdlam

Can you see if this is still an issue with 0.10.3 which has some fixes from https://github.com/adamlwgriffiths/Pyrr/pull/88

adamlwgriffiths avatar Apr 19 '19 14:04 adamlwgriffiths