本文整理汇总了C#中System.Vector4.ToVector3方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4.ToVector3方法的具体用法?C# Vector4.ToVector3怎么用?C# Vector4.ToVector3使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector4
的用法示例。
在下文中一共展示了Vector4.ToVector3方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsOrthogonal
/// <summary>
/// Returns if the angle is orthogonal.
/// </summary>
/// <param name="vector2">Extended SharpDX Vector2</param>
/// <param name="toVector4">SharpDX Vector2</param>
/// <returns>The <see cref="bool" />.</returns>
public static bool IsOrthogonal(this Vector2 vector2, Vector4 toVector4)
{
return IsOrthogonal(vector2, toVector4.ToVector3());
}
示例2: AngleBetween
/// <summary>
/// Returns the angle between two vectors.
/// </summary>
/// <param name="vector2">Extended SharpDX Vector2</param>
/// <param name="toVector4">SharpDX Vector4</param>
/// <returns>Angle between two vectors in float-units</returns>
public static float AngleBetween(this Vector2 vector2, Vector4 toVector4)
{
return AngleBetween(vector2, toVector4.ToVector3());
}
示例3: HitTest
public override bool HitTest(Ray rayWS, ref List<HitTestResult> hits)
{
LineGeometry3D lineGeometry3D;
Viewport3DX viewport;
if (this.Visibility == Visibility.Collapsed ||
this.IsHitTestVisible == false ||
(viewport = FindVisualAncestor<Viewport3DX>(this.renderHost as DependencyObject)) == null ||
(lineGeometry3D = this.Geometry as LineGeometry3D) == null)
{
return false;
}
// revert unprojection; probably better: overloaded HitTest() for LineGeometryModel3D?
var svpm = viewport.GetScreenViewProjectionMatrix();
var smvpm = this.modelMatrix * svpm;
var clickPoint4 = new Vector4(rayWS.Position + rayWS.Direction, 1);
Vector4.Transform(ref clickPoint4, ref svpm, out clickPoint4);
var clickPoint = clickPoint4.ToVector3();
var result = new HitTestResult { IsValid = false, Distance = double.MaxValue };
var maxDist = this.HitTestThickness;
var lastDist = double.MaxValue;
var index = 0;
foreach (var line in lineGeometry3D.Lines)
{
var p0 = Vector3.TransformCoordinate(line.P0, smvpm);
var p1 = Vector3.TransformCoordinate(line.P1, smvpm);
Vector3 hitPoint;
float t;
var dist = LineBuilder.GetPointToLineDistance2D(ref clickPoint, ref p0, ref p1, out hitPoint, out t);
if (dist < lastDist && dist <= maxDist)
{
lastDist = dist;
Vector4 res;
var lp0 = line.P0;
Vector3.Transform(ref lp0, ref this.modelMatrix, out res);
lp0 = res.ToVector3();
var lp1 = line.P1;
Vector3.Transform(ref lp1, ref this.modelMatrix, out res);
lp1 = res.ToVector3();
var lv = lp1 - lp0;
var hitPointWS = lp0 + lv * t;
result.Distance = (rayWS.Position - hitPointWS).Length();
result.PointHit = hitPointWS.ToPoint3D();
result.ModelHit = this;
result.IsValid = true;
result.Tag = index; // ToDo: LineHitTag with additional info
}
index++;
}
if (result.IsValid)
{
hits.Add(result);
}
return result.IsValid;
}
示例4: Distance3D
/// <summary>
/// Extension wrapper for Vector3.Distance method
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>The distance between two vectors</returns>
public static float Distance3D(this Vector4 v1, Vector4 v2)
{
return Vector3.Distance(v1.ToVector3(), v2.ToVector3());
}
示例5: IsOrthogonal
/// <summary>
/// Returns if the angle is orthogonal.
/// </summary>
/// <param name="vector3">Extended SharpDX Vector3</param>
/// <param name="toVector4">SharpDX Vector2</param>
/// <returns>Returns if the angle is orthogonal</returns>
public static bool IsOrthogonal(Vector3 vector3, Vector4 toVector4)
{
return IsOrthogonal(vector3, toVector4.ToVector3());
}
示例6: Extend
/// <summary>
/// Extends a Vector3 to a Vector4.
/// </summary>
/// <param name="vector3">Extended SharpDX Vector3 (From)</param>
/// <param name="toVector4">SharpDX Vector4 (To)</param>
/// <param name="distance">Distance (float units)</param>
/// <returns>Extended Vector3</returns>
public static Vector3 Extend(this Vector3 vector3, Vector4 toVector4, float distance)
{
return vector3 + distance * (toVector4.ToVector3() - vector3).Normalized();
}
示例7: DistanceSquared
/// <summary>
/// Calculates the squared distance between two vectors.
/// </summary>
/// <param name="vector3">Extended SharpDX Vector3</param>
/// <param name="toVector4">SharpDX Vector4</param>
/// <returns>The squared distance between the two vectors.</returns>
public static float DistanceSquared(this Vector3 vector3, Vector4 toVector4)
{
return Vector3.DistanceSquared(vector3, toVector4.ToVector3());
}