I
I
Ilya Malinovsky2019-08-20 19:38:50
JavaScript
Ilya Malinovsky, 2019-08-20 19:38:50

How to determine neighboring points?

There is a 3d scene on which there are many points, when choosing the Y point, I need to find the nearest points to the left and right.
I managed to determine the nearest points due to the distanceTo function

var myPoint = new THREE.Vector3(point.x, point.y, point.z)
for (var i = 0; i < points.length; i++) {
var vector = new THREE.Vector3(points[i].x, point.y, points[i].z);
//получаю дистанцию
myPoint.distanceTo(vector);
}

But the problem is that due to this I can determine the nearest points, but the sides are not taken into account here. And I just need to find the point on the left and right. Need ideas on how to make it work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Chuprik, 2019-10-27
@choupa

There is nothing easier to check that the point is to the right of myPoint:
point.x < point[i].x

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question