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

Confirmation of expected behaviour of mathutils.geometry.intersect_point_line for higher dimensions #12

Open
avyavkumar opened this issue Feb 13, 2022 · 1 comment

Comments

@avyavkumar
Copy link

From the documentation of mathutils.geometry.intersect_point_line the point closest to the given point on a line should be returned.

it looks like the method does not work for higher dimensions - the point returned has at most 3 dimensions. A quick check can reproduce this behaviour -

from mathutils.geometry import intersect_point_line
import numpy as np

pointA = np.arange(50)
pointB = np.arange(100, 150)
pointC = np.arange(200, 250)
pointD = np.arange(300, 350)
centroids = [pointA, pointB, pointC, pointD]
print(centroids)
for centroid in centroids:
  print(intersect_point_line(centroid, centroids[0], centroids[-1]))
[array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
       34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]), array([100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
       113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
       126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
       139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149]), array([200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
       213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
       226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238,
       239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249]), array([300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312,
       313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325,
       326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338,
       339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349])]
(Vector((0.0, 1.0, 2.0)), 0.0)
(Vector((100.0, 101.0, 102.0)), 0.3333333432674408)
(Vector((200.0, 201.0, 202.0)), 0.6666666865348816)
(Vector((300.0, 301.0, 302.0)), 1.0)

The points are 50 dimensional, however, only a 3D point is returned. I am assuming that this is incorrect behaviour and we would need to implement a separate function for higher dimensions. Please let me know if this is correct. Thanks!

@ilia10000
Copy link
Owner

Yeah, this seems like a mistake in Blender.
The expected behavior in their docs mentions nothing about restrictions on the dimensionality of the points as far as I can tell, but in the source code it seems to be hard-coded.
If I remember correctly, for the higher dimensional experiments we created a separate set of functions. Those would probably be the 'multiD' ones.

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