本文整理汇总了C#中XMVector类的典型用法代码示例。如果您正苦于以下问题:C# XMVector类的具体用法?C# XMVector怎么用?C# XMVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMVector类属于命名空间,在下文中一共展示了XMVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NearEqual
public static bool NearEqual(XMVector p1, XMVector p2, XMVector epsilon)
{
XMVector np1 = XMPlane.Normalize(p1);
XMVector np2 = XMPlane.Normalize(p2);
return XMVector4.NearEqual(np1, np2, epsilon);
}
示例2: FresnelTerm
public static XMVector FresnelTerm(XMVector cosIncidentAngle, XMVector refractionIndex)
{
Debug.Assert(!XMVector4.IsInfinite(cosIncidentAngle), "Reviewed");
//// Result = 0.5f * (g - c)^2 / (g + c)^2 * ((c * (g + c) - 1)^2 / (c * (g - c) + 1)^2 + 1) where
//// c = CosIncidentAngle
//// g = sqrt(c^2 + RefractionIndex^2 - 1)
XMVector g = XMVector.MultiplyAdd(refractionIndex, refractionIndex, XMGlobalConstants.NegativeOne);
g = XMVector.MultiplyAdd(cosIncidentAngle, cosIncidentAngle, g);
g = g.Abs().Sqrt();
XMVector s = XMVector.Add(g, cosIncidentAngle);
XMVector d = XMVector.Subtract(g, cosIncidentAngle);
XMVector v0 = XMVector.Multiply(d, d);
XMVector v1 = XMVector.Multiply(s, s).Reciprocal();
v0 = XMVector.Multiply(XMGlobalConstants.OneHalf, v0);
v0 = XMVector.Multiply(v0, v1);
XMVector v2 = XMVector.MultiplyAdd(cosIncidentAngle, s, XMGlobalConstants.NegativeOne);
XMVector v3 = XMVector.MultiplyAdd(cosIncidentAngle, d, XMGlobalConstants.One);
v2 = XMVector.Multiply(v2, v2);
v3 = XMVector.Multiply(v3, v3);
v3 = v3.Reciprocal();
v2 = XMVector.MultiplyAdd(v2, v3, XMGlobalConstants.One);
return XMVector.Multiply(v0, v2).Saturate();
}
示例3: EqualInt
public static bool EqualInt(XMVector v1, XMVector v2)
{
return ((uint*)&v1)[0] == ((uint*)&v2)[0]
&& ((uint*)&v1)[1] == ((uint*)&v2)[1]
&& ((uint*)&v1)[2] == ((uint*)&v2)[2]
&& ((uint*)&v1)[3] == ((uint*)&v2)[3];
}
示例4: XMVector3AllTrue
public static bool XMVector3AllTrue(XMVector v)
{
// Duplicate the fourth element from the first element.
XMVector c = new XMVector(v.X, v.Y, v.Z, v.X);
return XMVector4.EqualIntR(c, XMVector.TrueInt).IsAllTrue;
}
示例5: EqualR
public static XMComparisonRecord EqualR(XMVector v1, XMVector v2)
{
uint cr = 0;
if (v1.X == v2.X && v1.Y == v2.Y)
{
cr = XMComparisonRecord.MaskTrue;
}
else if (v1.X != v2.X && v1.Y != v2.Y)
{
cr = XMComparisonRecord.MaskFalse;
}
return new XMComparisonRecord(cr);
}
示例6: EqualIntR
public static XMComparisonRecord EqualIntR(XMVector v1, XMVector v2)
{
uint cr = 0;
if (((uint*)&v1)[0] == ((uint*)&v2)[0]
&& ((uint*)&v1)[1] == ((uint*)&v2)[1])
{
cr = XMComparisonRecord.MaskTrue;
}
else if (((uint*)&v1)[0] != ((uint*)&v2)[0]
&& ((uint*)&v1)[1] != ((uint*)&v2)[1])
{
cr = XMComparisonRecord.MaskFalse;
}
return new XMComparisonRecord(cr);
}
示例7: RefractV
public static XMVector RefractV(XMVector incident, XMVector normal, XMVector refractionIndex)
{
//// Result = RefractionIndex * Incident - Normal * (RefractionIndex * dot(Incident, Normal) +
//// sqrt(1 - RefractionIndex * RefractionIndex * (1 - dot(Incident, Normal) * dot(Incident, Normal))))
float incidentDotNormal = (incident.X * normal.X) + (incident.Y * normal.Y);
// R = 1.0f - RefractionIndex * RefractionIndex * (1.0f - IDotN * IDotN)
float rY = 1.0f - (incidentDotNormal * incidentDotNormal);
float rX = 1.0f - (rY * refractionIndex.X * refractionIndex.X);
rY = 1.0f - (rY * refractionIndex.Y * refractionIndex.Y);
if (rX >= 0.0f)
{
rX = (refractionIndex.X * refractionIndex.X) - (normal.X * ((refractionIndex.X * incidentDotNormal) + (float)Math.Sqrt(rX)));
}
else
{
rX = 0.0f;
}
if (rY >= 0.0f)
{
rY = (refractionIndex.Y * incident.Y) - (normal.Y * ((refractionIndex.Y * incidentDotNormal) + (float)Math.Sqrt(rY)));
}
else
{
rY = 0.0f;
}
return new XMVector(rX, rY, 0.0f, 0.0f);
}
示例8: Refract
public static XMVector Refract(XMVector incident, XMVector normal, float refractionIndex)
{
XMVector index = XMVector.Replicate(refractionIndex);
return XMVector2.RefractV(incident, normal, index);
}
示例9: Reflect
public static XMVector Reflect(XMVector incident, XMVector normal)
{
//// Result = Incident - (2 * dot(Incident, Normal)) * Normal
XMVector result;
result = XMVector2.Dot(incident, normal);
result = XMVector.Add(result, result);
result = XMVector.NegativeMultiplySubtract(result, normal, incident);
return result;
}
示例10: InBounds
public static bool InBounds(XMVector v, XMVector bounds)
{
return v.X <= bounds.X && v.X >= -bounds.X
&& v.Y <= bounds.Y && v.Y >= -bounds.Y;
}
示例11: NearEqual
public static bool NearEqual(XMVector v1, XMVector v2, XMVector epsilon)
{
float dx = Math.Abs(v1.X - v2.X);
float dy = Math.Abs(v1.Y - v2.Y);
return dx <= epsilon.X
&& dy <= epsilon.Y;
}
示例12: AngleBetweenVectors
public static XMVector AngleBetweenVectors(XMVector v1, XMVector v2)
{
XMVector l1 = XMVector2.ReciprocalLength(v1);
XMVector l2 = XMVector2.ReciprocalLength(v2);
XMVector dot = XMVector2.Dot(v1, v2);
l1 = XMVector.Multiply(l1, l2);
return XMVector.Multiply(dot, l1)
.Clamp(XMGlobalConstants.NegativeOne, XMGlobalConstants.One)
.ACos();
}
示例13: IntersectLine
public static XMVector IntersectLine(XMVector line1Point1, XMVector line1Point2, XMVector line2Point1, XMVector line2Point2)
{
XMVector v1 = XMVector.Subtract(line1Point2, line1Point1);
XMVector v2 = XMVector.Subtract(line2Point2, line2Point1);
XMVector v3 = XMVector.Subtract(line1Point1, line2Point1);
XMVector c1 = XMVector2.Cross(v1, v2);
XMVector c2 = XMVector2.Cross(v2, v3);
XMVector result;
XMVector zero = XMVector.Zero;
if (XMVector2.NearEqual(c1, zero, XMGlobalConstants.Epsilon))
{
if (XMVector2.NearEqual(c2, zero, XMGlobalConstants.Epsilon))
{
// Coincident
result = XMGlobalConstants.Infinity;
}
else
{
// Parallel
result = XMGlobalConstants.QNaN;
}
}
else
{
//// Intersection point = Line1Point1 + V1 * (C2 / C1)
XMVector scale = c1.Reciprocal();
scale = XMVector.Multiply(c2, scale);
result = XMVector.MultiplyAdd(v1, scale, line1Point1);
}
return result;
}
示例14: ReciprocalLength
public static XMVector ReciprocalLength(XMVector v)
{
return XMVector2.LengthSquare(v)
.ReciprocalSqrt();
}
示例15: Orthogonal
public static XMVector Orthogonal(XMVector v)
{
return new XMVector(-v.Y, v.X, 0.0f, 0.0f);
}