【发布时间】:2012-04-13 06:48:07
【问题描述】:
- 我得到了一个
Plane(正常,d)和一个Vector3点(x,y,z)。 - 我需要将平面平移到 X 距离的那个点。我该怎么做?
我想出了这个..
plane = Plane.Transform(plane, Matrix.CreateTranslation(
但不知道该放什么。它必须是点积,Plane.Normal 和我的Vector3。
编辑:
我在想这个。
public static Plane MoveTo(this Plane p, Vector3 point, float distance)
{
Vector3 planeVector = p.Normal * p.D;
Matrix matrix = Matrix.CreateTranslation(Vector3.Normalize(planeVector)) *
distance * Math.Sign(Vector3.Dot(planeVector, point - planeVector))
return Plane.Transform(p, matrix);
}
如果有人认为这是错误的或部分错误的,请注意。
【问题讨论】:
-
@hamad 不,我没有,但我使用相同的方法。我只需要一种方法。
-
那么它对你有用吗?创建一个新矩阵并将其传递给 Plane.Transform()
-
@hamad 我不知道要传递给矩阵创建方法的参数。
标签: c# xna translation plane