本文整理汇总了C#中Point3d.normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Point3d.normalize方法的具体用法?C# Point3d.normalize怎么用?C# Point3d.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point3d
的用法示例。
在下文中一共展示了Point3d.normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectOnMeshBase
// Project an elevated mesh point to the mesh base
private Point3d ProjectOnMeshBase(Point3d p)
{
p = p + this.localOrigin;
p = p.normalize();
p = p * meshBaseRadius - this.localOrigin;
return p;
}
示例2: ComputeViewMatrix
public virtual void ComputeViewMatrix()
{
ComputeAbsoluteMatrices();
if (World.Settings.ElevateCameraLookatPoint) {
targetCameraElevation = TerrainElevation*World.Settings.VerticalExaggeration;
curCameraElevation = curCameraElevation + (0.01f*(targetCameraElevation - curCameraElevation));
}
else {
curCameraElevation = 0;
}
// needs to be double precsion
double radius = WorldRadius + curCameraElevation;
double radCosLat = radius*Math.Cos(_latitude.Radians);
LookFrom = new Point3d(radCosLat*Math.Cos(_longitude.Radians), radCosLat*Math.Sin(_longitude.Radians), radius*Math.Sin(_latitude.Radians));
// this constitutes a local tri-frame hovering above the sphere
Point3d zAxis = LookFrom.normalize(); // on sphere the normal vector and position vector are the same
Point3d xAxis = Point3d.cross(cameraUpVector, zAxis).normalize();
Point3d yAxis = Point3d.cross(zAxis, xAxis);
ReferenceCenter = MathEngine.SphericalToCartesianD(Angle.FromRadians(Convert.ToSingle(_latitude.Radians)), Angle.FromRadians(Convert.ToSingle(_longitude.Radians)), WorldRadius);
// Important step !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// In order to use single precsion rendering, we need to define a local frame (i.e. center of center tile, etc.)
// Vector3d LocalCenter should be defined & initialized in the CameraBase class
// Each time the camera moves, a new local center could be defined
// The local center also has to be subtracted from all the terrain vertices!!!!
relCameraPos = LookFrom - ReferenceCenter;
// Important step: construct the single precision m_ViewMatrix by hand
// We can build the m_ViewMatrix by hand
m_ViewMatrix.M11 = (float) xAxis.X;
m_ViewMatrix.M21 = (float) xAxis.Y;
m_ViewMatrix.M31 = (float) xAxis.Z;
m_ViewMatrix.M12 = (float) yAxis.X;
m_ViewMatrix.M22 = (float) yAxis.Y;
m_ViewMatrix.M32 = (float) yAxis.Z;
m_ViewMatrix.M13 = (float) zAxis.X;
m_ViewMatrix.M23 = (float) zAxis.Y;
m_ViewMatrix.M33 = (float) zAxis.Z;
m_ViewMatrix.M41 = -(float) (xAxis.X*relCameraPos.X + xAxis.Y*relCameraPos.Y + xAxis.Z*relCameraPos.Z);
m_ViewMatrix.M42 = -(float) (yAxis.X*relCameraPos.X + yAxis.Y*relCameraPos.Y + yAxis.Z*relCameraPos.Z);
m_ViewMatrix.M43 = -(float) (zAxis.X*relCameraPos.X + zAxis.Y*relCameraPos.Y + zAxis.Z*relCameraPos.Z);
m_ViewMatrix.M14 = (float) 0.0;
m_ViewMatrix.M24 = (float) 0.0;
m_ViewMatrix.M34 = (float) 0.0;
m_ViewMatrix.M44 = (float) 1.0;
m_ViewMatrix *= Matrix.RotationYawPitchRoll(0, (float) -_tilt.Radians, (float) _heading.Radians);
m_ViewMatrix *= Matrix.Translation(0, 0, (float) (-_distance - curCameraElevation));
m_ViewMatrix *= Matrix.RotationZ((float) _bank.Radians);
// Extract camera position
Matrix cam = Matrix.Invert(m_absoluteViewMatrix);
_position = new Vector3(cam.M41, cam.M42, cam.M43);
}