本文整理汇总了C#中Vector3f.Normalized方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3f.Normalized方法的具体用法?C# Vector3f.Normalized怎么用?C# Vector3f.Normalized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3f
的用法示例。
在下文中一共展示了Vector3f.Normalized方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateAxis
public static Matrix3f RotateAxis( Vector3f axis, float radians )
{
var normalizedAxis = axis.Normalized();
float cosTheta = ( float )( Math.Cos( radians ) );
float sinTheta = ( float )( Math.Sin( radians ) );
float x = normalizedAxis.x;
float y = normalizedAxis.y;
float z = normalizedAxis.z;
var m = new Matrix3f();
m[ 0, 0 ] = x * x * ( 1.0f - cosTheta ) + cosTheta;
m[ 0, 1 ] = y * x * ( 1.0f - cosTheta ) - z * sinTheta;
m[ 0, 2 ] = z * x * ( 1.0f - cosTheta ) + y * sinTheta;
m[ 1, 0 ] = x * y * ( 1.0f - cosTheta ) + z * sinTheta;
m[ 1, 1 ] = y * y * ( 1.0f - cosTheta ) + cosTheta;
m[ 1, 2 ] = z * y * ( 1.0f - cosTheta ) - x * sinTheta;
m[ 2, 0 ] = x * z * ( 1.0f - cosTheta ) - y * sinTheta;
m[ 2, 1 ] = y * z * ( 1.0f - cosTheta ) + x * sinTheta;
m[ 2, 2 ] = z * z * ( 1.0f - cosTheta ) + cosTheta;
return m;
}
示例2: Camera
public Camera(Vector3f position, Vector3f forward, Vector3f worldUp, float fieldOfView, Size renderSize)
: base(position)
{
this.ReflectionDepth = 5;
this.forward = forward.Normalized();
this.right = Util.CrossProduct(worldUp, forward).Normalized();
this.up = -Util.CrossProduct(right, forward).Normalized();
this.fieldOfView = fieldOfView;
this.RenderSize = renderSize;
RecalculateFieldOfView();
}
示例3: Plane
/// <summary>
/// Constructs a plane with the properties provided
/// </summary>
/// <param name="position">The position of the plane's center</param>
/// <param name="material">The plane's material</param>
/// <param name="normalDirection">The normal direction of the plane</param>
/// <param name="cellWidth">The width of a cell in the plane, used for texture coordinate mapping.</param>
public Plane(Vector3f position, Material material, Vector3f normalDirection, float cellWidth)
: base(position, material)
{
this.normalDirection = normalDirection.Normalized();
if (normalDirection == Util.ForwardVector)
{
this.uDirection = -Util.RightVector;
}
else if (normalDirection == -Util.ForwardVector)
{
this.uDirection = Util.RightVector;
}
else
{
this.uDirection = Util.CrossProduct(normalDirection, Util.ForwardVector).Normalized();
}
this.vDirection = -Util.CrossProduct(normalDirection, uDirection).Normalized();
this.cellWidth = cellWidth;
}
示例4: Basis
/// <summary>
/// Returns an orthonormal basis u, v, and n on the plane
/// given a preferred u vector. If u is not on the plane,
/// then u is projected onto the plane first
/// </summary>
/// <param name="u"></param>
/// <returns></returns>
public Matrix3f Basis( Vector3f u )
{
// normalize u first
u = u.Normalized();
var n = UnitNormal;
// u is the vector triple product: ( n x u ) x n
//
// u is the preferred direction, which may be be in the plane
// we want u to be the projection of u in the plane
// and v to be perpendicular to both
// but v is n cross u regardless of whether u is in the plane or not
// so compute v, then cross v with n to get u in the plane
var v = Vector3f.Cross( n, u ).Normalized();
u = Vector3f.Cross( v, n ).Normalized();
return new Matrix3f( u, v, n );
}
示例5: Plane3f
/// <summary>
/// Construct a plane given a point on the plane and its normal (does not need to be unit length)
/// </summary>
/// <param name="p"></param>
/// <param name="normal"></param>
public Plane3f( Vector3f p, Vector3f normal )
{
var unitNormal = normal.Normalized();
var d = -Vector3f.Dot( unitNormal, p );
ABCD = new Vector4f( unitNormal, d );
}
示例6: Projection
public static Vector3f Projection(Vector3f projectedVector, Vector3f directionVector)
{
var mag = VectorMath.DotProduct(projectedVector, directionVector.Normalized());
return directionVector * mag;
}
示例7: Ray
public Ray(Vector3f start, Vector3f direction, float distance)
{
this.Origin = start;
this.Direction = direction.Normalized();
this.Distance = distance;
}