/** * \return Point on this shape that is closest to p. Based on getVectorTo. */ RVector RShape::getClosestPointOnShape(const RVector& p, bool limited) const { RVector dv = getVectorTo(p, limited); if (!dv.isValid()) { return RVector::invalid; } return p - dv; }
Length Vector3D::getGroundRangeTo(const Vector3D &other) { Vector3D diff = getVectorTo(other); double x = diff.getX().getDoubleValue(Length::METERS); double y = diff.getY().getDoubleValue(Length::METERS); double dist = sqrt( x*x + y*y ); return Length(dist, Length::METERS); }
/** * \return Shortest distance from this shape to the given point. * Based on \ref getVectorTo. */ double RShape::getDistanceTo(const RVector& point, bool limited) const { RVector v = getVectorTo(point, limited); if (v.isValid()) { return v.getMagnitude(); } return RNANDOUBLE; }
NorthBearingAngle Vector3D::getBearingTo(const Vector3D &other) { Vector3D diff = getVectorTo(other); if (diff == Vector3D::ZERO) return NorthBearingAngle::NORTH; double x = diff.getX().getDoubleValue(Length::METERS); double y = diff.getY().getDoubleValue(Length::METERS); Angle ang( atan2(y,x), Angle::RADIANS ); return ang.toNorthBearing(); }
/** * \return The shortest distance from this entity to the given point. */ double REntityData::getDistanceTo(const RVector& point, bool limited, double range, bool draft) const { Q_UNUSED(range); Q_UNUSED(draft); RVector v = getVectorTo(point, limited); if (v.isValid()) { return v.getMagnitude(); } return RNANDOUBLE; }