How can I find a point placed between 2 points for

2020-04-18 04:30发布

Given 2 points A(x0,y0,z0) and C(x2,y2,z2) forming a segment of length "k", what is the equation to find a point C(x1,y1,z1) placed at "k-1" distance from A?

标签: 3d geometry
2条回答
疯言疯语
2楼-- · 2020-04-18 05:24

This is basic maths. If you already have classes handling vectors and points, you should be able to do something like this:

Vector direction = C - A;
direction.Normalize();
Point newpoint = A + (k-1) * direction;

You just need

  • difference between points (gives a vector)

  • scalar product of a float with a vector (gives a new vector)

  • addition of a point and a vector (gives a new point)

查看更多
淡お忘
3楼-- · 2020-04-18 05:28

Smells like homework, so, general idea, but no code:

Get the slope of AC for each coordinate set (x, y, and z). Then progress k-1 units from A at each of the calculated slope to get the coordinates of the new point.

查看更多
登录 后发表回答