本文整理汇总了C#中Plane.Dot方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.Dot方法的具体用法?C# Plane.Dot怎么用?C# Plane.Dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane.Dot方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: intersectMovingSpherePlane
/// <summary>
/// Detecta colision entre una esfera que se esta moviendo contra un plano.
/// Si hay colision devuelve el instante t de la colision y el punto q de colision.
/// </summary>
/// <param name="sphere">BoundingSphere</param>
/// <param name="velocity">Vector de movimiento de la esfera</param>
/// <param name="plane">Plano</param>
/// <param name="t">Instante de colision en el intervalo [0, 1]</param>
/// <param name="q">Punto de colision</param>
/// <returns>True si hay colision</returns>
public static bool intersectMovingSpherePlane(TgcBoundingSphere sphere, Vector3 velocity, Plane plane, out float t, out Vector3 q)
{
// Compute distance of sphere center to plane
float dist = plane.Dot(sphere.Center);
if (FastMath.Abs(dist) <= sphere.Radius) {
// The sphere is already overlapping the plane. Set time of
// intersection to zero and q to sphere center
t = 0.0f;
q = sphere.Center;
return true;
} else {
Vector3 p_n = getPlaneNormal(plane);
float denom = Vector3.Dot(p_n, velocity);
if (denom * dist >= 0.0f) {
// No intersection as sphere moving parallel to or away from plane
t = -1;
q = Vector3.Empty;
return false;
} else {
// Sphere is moving towards the plane
// Use +r in computations if sphere in front of plane, else -r
float r = dist > 0.0f ? sphere.Radius : -sphere.Radius;
t = (r - dist) / denom;
q = sphere.Center + t * velocity - r * p_n;
if (t > 1) return false;
return true;
}
}
}
示例2: intersectRayPlane
/// <summary>
/// Indica si un Ray colisiona con un Plano.
/// Tanto la normal del plano como la dirección del Ray se asumen normalizados.
/// </summary>
/// <param name="ray">Ray a testear</param>
/// <param name="plane">Plano a testear</param>
/// <param name="t">Instante de colisión</param>
/// <param name="q">Punto de colisión con el plano</param>
/// <returns>True si hubo colisión</returns>
public static bool intersectRayPlane(TgcRay ray, Plane plane, out float t, out Vector3 q)
{
Vector3 planeNormal = TgcCollisionUtils.getPlaneNormal(plane);
float numer = plane.Dot(ray.Origin);
float denom = Vector3.Dot(planeNormal, ray.Direction);
t = -numer / denom;
if(t > 0.0f)
{
q = ray.Origin + ray.Direction * t;
return true;
}
q = Vector3.Empty;
return false;
}
示例3: distPointPlane
/// <summary>
/// Indica la distancia de un punto al plano
/// </summary>
/// <param name="q">Punto a testear</param>
/// <param name="p">Plano</param>
/// <returns>Distancia del punto al plano</returns>
public static float distPointPlane(Vector3 q, Plane p)
{
/*
Vector3 p_n = toVector3(p);
return (Vector3.Dot(p_n, q) + p.D) / Vector3.Dot(p_n, p_n);
*/
return p.Dot(q);
}
示例4: classifyPlaneAABB
/// <summary>
/// Clasifica un BoundingBox respecto de un Plano.
/// </summary>
/// <param name="plane">Plano</param>
/// <param name="aabb">BoundingBox</param>
/// <returns>
/// Resultado de la clasificación.
/// </returns>
///
public static PlaneBoxResult classifyPlaneAABB(Plane plane, TgcBoundingBox aabb)
{
Vector3 vmin = Vector3.Empty;
Vector3 vmax = Vector3.Empty;
//Obtener puntos minimos y maximos en base a la dirección de la normal del plano
if (plane.A >= 0f)
{
vmin.X = aabb.PMin.X;
vmax.X = aabb.PMax.X;
}
else
{
vmin.X = aabb.PMax.X;
vmax.X = aabb.PMin.X;
}
if (plane.B >= 0f)
{
vmin.Y = aabb.PMin.Y;
vmax.Y = aabb.PMax.Y;
}
else
{
vmin.Y = aabb.PMax.Y;
vmax.Y = aabb.PMin.Y;
}
if (plane.C >= 0f)
{
vmin.Z = aabb.PMin.Z;
vmax.Z = aabb.PMax.Z;
}
else
{
vmin.Z = aabb.PMax.Z;
vmax.Z = aabb.PMin.Z;
}
//Analizar punto minimo y maximo contra el plano
PlaneBoxResult result;
if (plane.Dot(vmin) > 0f)
{
result = PlaneBoxResult.IN_FRONT_OF;
}
else if(plane.Dot(vmax) > 0f)
{
result = PlaneBoxResult.INTERSECT;
}
else
{
result = PlaneBoxResult.BEHIND;
}
return result;
}
示例5: testPlaneAABB
/// <summary>
/// Indica si un Plano colisiona con un BoundingBox
/// </summary>
/// <param name="plane">Plano</param>
/// <param name="aabb">BoundingBox</param>
/// <returns>True si hay colisión.</returns>
public static bool testPlaneAABB(Plane plane, TgcBoundingBox aabb)
{
Vector3 c = (aabb.PMax + aabb.PMin) * 0.5f; // Compute AABB center
Vector3 e = aabb.PMax - c; // Compute positive extents
// Compute the projection interval radius of b onto L(t) = b.c + t * p.n
float r = e.X * FastMath.Abs(plane.A) + e.Y * FastMath.Abs(plane.B) + e.Z * FastMath.Abs(plane.C);
// Compute distance of box center from plane
float s = plane.Dot(c);
// Intersection occurs when distance s falls within [-r,+r] interval
return FastMath.Abs(s) <= r;
}
示例6: testMovingSpherePlane
/// <summary>
/// Indica si una esfera que se esta moviendo colisiona contra un plano.
/// Solo indica si hay colision. No calcula el punto de colision.
/// Es mas eficiente que el metodo: "intersectMovingSpherePlane()"
/// </summary>
/// <param name="sphere">BoundingSphere</param>
/// <param name="velocity">Vector de movimiento de la esfera</param>
/// <param name="plane">Plano</param>
/// <returns>True si hay colision</returns>
public static bool testMovingSpherePlane(TgcBoundingSphere sphere, Vector3 velocity, Plane plane)
{
Vector3 a = sphere.Center;
Vector3 b = sphere.Center + velocity;
// Get the distance for both a and b from plane p
float adist = plane.Dot(a);
float bdist = plane.Dot(b);
// Intersects if on different sides of plane (distances have different signs)
if (adist * bdist < 0.0f) return true;
// Intersects if start or end position within radius from plane
if (FastMath.Abs(adist) <= sphere.Radius || FastMath.Abs(bdist) <= sphere.Radius) return true;
// No intersection
return false;
}
示例7: intersectSegmentPlane
/// <summary>
/// Indica si el segmento de recta compuesto por a-b colisiona con el Plano.
/// La normal del plano se considera normalizada.
/// </summary>
/// <param name="a">Punto inicial del segmento</param>
/// <param name="b">Punto final del segmento</param>
/// <param name="plane">Plano a testear</param>
/// <param name="t">Instante de colisión</param>
/// <param name="q">Punto de colisión</param>
/// <returns>True si hay colisión</returns>
public static bool intersectSegmentPlane(Vector3 a, Vector3 b, Plane plane, out float t, out Vector3 q)
{
Vector3 planeNormal = getPlaneNormal(plane);
//t = -(n.A + d / n.(B - A))
Vector3 ab = b - a;
t = -(plane.Dot(a)) / (Vector3.Dot(planeNormal, ab));
// If t in [0..1] compute and return intersection point
if (t >= 0.0f && t <= 1.0f)
{
q = a + t * ab;
return true;
}
q = Vector3.Empty;
return false;
}