本文整理汇总了C#中OpenTK.Vector3.Normalized方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Normalized方法的具体用法?C# Vector3.Normalized怎么用?C# Vector3.Normalized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenTK.Vector3
的用法示例。
在下文中一共展示了Vector3.Normalized方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Spotlight
//Spotlight constructor, takes a position Vector, a color Vector, a direction Vector and
public Spotlight(Vector3 position, Vector3 color, Vector3 direction, float minDot)
{
pos = position;
this.color = color;
D = direction.Normalized();
this.minDot = minDot;
}
示例2: Ray
public Ray(Vector3 origin, Vector3 direction)
{
Origin = origin;
Direction = direction.Normalized();
}
示例3: hits
public Primitive objectHit; //The primitive the ray hits (if applicable).
public Ray(Vector3 Origin, Vector3 Direction, float length)
{
O = Origin;
D = Direction.Normalized();
l = length;
}
示例4: ConstraintLookAt
public void ConstraintLookAt(Vector3 targetAbsRef, Vector3 upRelRef, Vector3 constraintAxisSelect)
{
Vector3 targetRelRef;
if (IsChild)
targetRelRef = Geometric.Quaternion_Rotate(_parentModel.Orientation.Inverted(), targetAbsRef);
else
targetRelRef = targetAbsRef;
if (constraintAxisSelect.X != 0)
targetRelRef.X = 0;
else if (constraintAxisSelect.Y != 0)
targetRelRef.Y = 0;
else if (constraintAxisSelect.Z != 0)
targetRelRef.Z = 0;
//Vector v1 = new Vector3(0, 0, -1);
//Vector moveV = _staticModel.Position - vector;
//Vector v2 = moveV.RotateBy(_staticModel.Orientation.W, 0, 1, 0);
/*Vector forward = lookAt.Normalized();
Vector right = Vector::Cross(up.Normalized(), forward);
Vector up = Vector::Cross(forward, right);*/
Vector3 forward;
if (IsChild)
{
//Normalizing target and transforming it to local system
forward = targetRelRef.Normalized() - _parentModel.Position;
}
else
{
//Normalizing target.. local system is the same as world system
forward = targetRelRef.Normalized();
}
//Normalizing upVector (we are assuming it is expressed in local system)
Vector3 eye = _position.Normalized();
Vector3 up = upRelRef.Normalized();
//Insert manual imprecision to avoid singularity
if (Vector3.Dot(forward, up) == 1)
{
forward.X += 0.001f;
forward.Y += 0.001f;
forward.Z += 0.001f;
}
//float angle = (float)Math.Acos( Vector3.Dot(current,targetAbsRef) );
//Vector3 rotAxis = Vector3.CrossProduct(current, forward).Normalized();
//Vector3 right = Vector3.CrossProduct(forward, up);
Matrix4 lookAt_result = Matrix4.LookAt(eye.X, eye.Y, eye.Z, forward.X, forward.Y, forward.Z, up.X, up.Y, up.Z);
Matrix3 targetRelOrientation_matrix = new Matrix3(lookAt_result);
Quaternion targetRelOrientation_quaternion = Quaternion.FromMatrix(targetRelOrientation_matrix);
/*
Quaternion targetRelOrientation_quaternion = new Quaternion();
targetRelOrientation_quaternion.W = (float)Math.Sqrt((double)(1.0f + right.X + up.Y + forward.Z)) * 0.5f;
float w4_recip = 1.0f / (4.0f * targetRelOrientation_quaternion.W);
targetRelOrientation_quaternion.X = (forward.Y - up.Z) * w4_recip;
targetRelOrientation_quaternion.Y = (right.Z - forward.X) * w4_recip;
targetRelOrientation_quaternion.Z = (up.X - right.Y) * w4_recip;
*/
_orientation = targetRelOrientation_quaternion;
}