Exemplo n.º 1
0
bool Polygon::Intersects(const Plane &plane) const
{
    Line intersectLine;
    bool intersects = plane.Intersects(PlaneCCW(), &intersectLine);
    if (!intersects)
        return false;
    return Intersects(intersectLine);
}
Exemplo n.º 2
0
bool Plane::Intersects(const Plane &plane, const Plane &plane2, Line *outLine, vec *outPoint) const
{
	Line dummy;
	if (!outLine)
		outLine = &dummy;

	// First check all planes for parallel pairs.
	if (this->IsParallel(plane) || this->IsParallel(plane2))
	{
		if (EqualAbs(d, plane.d) || EqualAbs(d, plane2.d))
		{
			bool intersect = plane.Intersects(plane2, outLine);
			if (intersect && outPoint)
				*outPoint = outLine->GetPoint(0);
			return intersect;
		}
		else
			return false;
	}
	if (plane.IsParallel(plane2))
	{
		if (EqualAbs(plane.d, plane2.d))
		{
			bool intersect = this->Intersects(plane, outLine);
			if (intersect && outPoint)
				*outPoint = outLine->GetPoint(0);
			return intersect;
		}
		else
			return false;
	}

	// All planes point to different directions.
	float3x3 m;
	m.SetRow(0, DIR_TO_FLOAT3(normal));
	m.SetRow(1, DIR_TO_FLOAT3(plane.normal));
	m.SetRow(2, DIR_TO_FLOAT3(plane2.normal));
	float3 intersectionPos;
	bool success = m.SolveAxb(float3(d, plane.d, plane2.d), intersectionPos);
	if (!success)
		return false;
	if (outPoint)
		*outPoint = POINT_VEC(intersectionPos);
	return true;
}
Exemplo n.º 3
0
bool Plane::Intersects(const Plane &plane, const Plane &plane2, Line *outLine, float3 *outPoint) const
{
    Line dummy;
    if (!outLine)
        outLine = &dummy;

    // First check all planes for parallel pairs.
    if (this->IsParallel(plane) || this->IsParallel(plane2))
    {
        if (EqualAbs(d, plane.d) || EqualAbs(d, plane2.d))
        {
            bool intersect = plane.Intersects(plane2, outLine);
            if (intersect && outPoint)
                *outPoint = outLine->GetPoint(0);
            return intersect;
        }
        else
            return false;
    }
    if (plane.IsParallel(plane2))
    {
        if (EqualAbs(plane.d, plane2.d))
        {
            bool intersect = this->Intersects(plane, outLine);
            if (intersect && outPoint)
                *outPoint = outLine->GetPoint(0);
            return intersect;
        }
        else
            return false;
    }

    // All planes point to different directions.
    float3x3 m;
    m.SetRow(0, normal);
    m.SetRow(1, plane.normal);
    m.SetRow(2, plane2.normal);
    bool success = m.Inverse();
    if (!success)
        return false;
    if (outPoint)
        *outPoint = m * float3(d, plane.d, plane2.d);
    return true;
}
Exemplo n.º 4
0
bool Sphere::Intersects(const Plane &plane) const
{
	return plane.Intersects(*this);
}
Exemplo n.º 5
0
bool AABB::Intersects(const Plane &plane) const
{
	return plane.Intersects(*this);
}
Exemplo n.º 6
0
bool Frustum::Intersects(const Plane &plane) const
{
	return plane.Intersects(*this);
}
Exemplo n.º 7
0
Arquivo: Ray.cpp Projeto: Ilikia/naali
bool Ray::Intersects(const Plane &plane, float *d) const
{
    return plane.Intersects(*this, d);
}
Exemplo n.º 8
0
bool Ray::Intersects(const Plane &plane) const
{
	return plane.Intersects(*this, 0);
}
Exemplo n.º 9
0
bool Triangle::Intersects(const Plane &plane) const
{
    return plane.Intersects(*this);
}
Exemplo n.º 10
0
int Circle::Intersects(const Plane &plane) const
{
	return plane.Intersects(*this);
}
Exemplo n.º 11
0
int Circle::Intersects(const Plane &plane, float3 *pt1, float3 *pt2) const
{
	return plane.Intersects(*this, pt1, pt2);
}
Exemplo n.º 12
0
bool Polyhedron::Intersects(const Plane &plane) const
{
	return plane.Intersects(*this);
}