如何仅使用线段的部分长度找到位于形成线段的 2 点之间的点? [英] How can I find a point placed between 2 points forming a segment using only the partial length of the segment?

查看:18
本文介绍了如何仅使用线段的部分长度找到位于形成线段的 2 点之间的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定 2 个点 A(x0,y0,z0) 和 C(x2,y2,z2) 形成一个长度为 "k" 的线段,找到放置在的点 C(x1,y1,z1) 的等式是什么k-1"距离A?

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?

推荐答案

这是基础数学.如果你已经有处理向量和点的类,你应该可以做这样的事情:

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;

你只需要

  • 点之间的差异(给出一个向量)

  • 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)

这篇关于如何仅使用线段的部分长度找到位于形成线段的 2 点之间的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆