Example #1
0
double Edge3D::distance(const Point3D &p) const
{
	Vector3D vec = Vector3D(this->vector());
	Vector3D ac(*(Point3D *)(this->getP1()), p);

	if (ac.cosAngle(vec) < 0.0001)
    {
    	return this->getP1()->distance(p);
    }

    vec.invert();

    ac = Vector3D(*(Point3D *)(this->getP2()), p);

    if (ac.cosAngle(vec) < 0.0001)
    {
    	return this->getP2()->distance(p);
    }

    return this->height(p);

	/*Vector3D vec = Vector3D(this->vector());
	vec.normalize();

	Vector3D ac(*(Point3D *)(this->getP1()), p);
	ac.normalize();

	if (ac.dot(vec) < Shape::getTolerance())
	{
    	return this->getP1()->distance(p);
    }

    vec.invert();

    ac = Vector3D(*(Point3D *)(this->getP2()), p);
    ac.normalize();

    if (ac.dot(vec) < Shape::getTolerance())
    {
    	return this->getP2()->distance(p);
    }

    return this->height(p);*/
}
Example #2
0
void Solido::teleportar(Solido *s) {
    Vector3D p = s->getP();

    p.invert();
    s->setP(p);
}