如下图,已知三维空间一条线段ab,已知c点在线段ab上,且已知ac的长度,求:c点坐标。
解法一:通过比例尺计算
private void Eval()
{
XYZ a = new XYZ(4, 0, 0);
XYZ b = new XYZ(5, 0, 0);
Autodesk.Revit.DB.Line line = Autodesk.Revit.DB.Line.CreateBound(a, b);
double acLength = 0.4;
XYZ c = line.Evaluate(acLength / line.ApproximateLength, true);
TaskDialog.Show("结果", c.ToString());
}
解法二:通过单位向量来计算
private void Eval()
{
XYZ a = new XYZ(4, 0, 0);
XYZ b = new XYZ(5, 0, 0);
Autodesk.Revit.DB.Line line = Autodesk.Revit.DB.Line.CreateBound(a, b);
double acLength = 0.4;
XYZ c = a + (b - a).Normalize() * acLength;
TaskDialog.Show("结果", c.ToString());
}
结果如下图所示:
祝您用餐愉快。