How to calculate point in a string in CGAL

Given the 3D line in CGAL, how do I calculate a point on this line, which is some known distance from the end point?

+5
source share
1 answer

If you have two points P 0 and P 1 , you can make the vector V = P 1 - P 0sub>.

Given the distance D from P 0 , you can get the resulting point R = P 0 + (D ÷ || V ||) ⋅ V.

(Interpolate linearly between lines, changing D by a percentage, dividing by the entire length of the line.)


CGAL ( ), , :

Line_3<K> l = /* ... */;
Vector_3<K> v = l.to_vector();
Point_3<K> r = l.p + (d * d / v.squared_length()) * v;

. , . ( ​​ l.p.)

+3

All Articles