Ejemplo n.º 1
0
float DistanceLinePoint(Point2f const &a, Point2f const &b, Point2f const &c,
                        bool isSegment)
{
    if (isSegment)
    {
        float dot1 = DotProductPoints(a, b, c);
        if (dot1 > 0) return DistancePointPoint(b, c);

        float dot2 = DotProductPoints(b, a, c);
        if (dot2 > 0) return DistancePointPoint(a, c);
    }

    //return fabs(CrossProductPoints(a, b, c) / DistancePointPoint(a, b));
    return CrossProductPoints(a, b, c) / DistancePointPoint(a, b);
}
Ejemplo n.º 2
0
float DistancePointSphere ( Vector const & V, Sphere const & S )
{
	float dist = DistancePointPoint(V,S.getCenter()) - S.getRadius();

	if(dist < 0.0f) dist = 0.0f;

	return dist;
}
Ejemplo n.º 3
0
real    DistancePointTri ( Vector const & V, Triangle3d const & T )
{
	Vector P = ClosestPointTri(V,T);

	return DistancePointPoint(P,V);
}
Ejemplo n.º 4
0
real DistancePointOBox ( Vector const & V, OrientedBox const & B )
{
	Vector close = ClosestPointOBox(V,B);

	return DistancePointPoint(V,close);
}
Ejemplo n.º 5
0
real DistancePointYBox ( Vector const & V, YawedBox const & B )
{
	Vector close = ClosestPointYBox(V,B);

	return DistancePointPoint(V,close);
}
Ejemplo n.º 6
0
real DistancePointABox ( Vector const & V, AxialBox const & B )
{
	Vector close = ClosestPointABox(V,B);

	return DistancePointPoint(V,close);
}
Ejemplo n.º 7
0
real DistancePointCylinder ( Vector const & V, Cylinder const & C )
{
	Vector close = ClosestPointCylinder(V,C);

	return DistancePointPoint(V,close);
}
Ejemplo n.º 8
0
real DistancePointPoly ( Vector const & V, VertexList const & vertices )
{
	Vector P = ClosestPointPoly(V,vertices);

	return DistancePointPoint(P,V);
}