[Positioner] Add Point3D::rotate_2d()
This commit is contained in:
parent
88a90a7abd
commit
291ef457f5
|
@ -97,6 +97,24 @@ double Point3D::angle_2d(const Point3D &b, const Point3D &c) const
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* #x and #y are updated with the rotated image of the point.
|
||||
*
|
||||
* Note that as this functions does a 2D rotation, the c.z is ignored,
|
||||
* and so is this->x.
|
||||
*/
|
||||
void Point3D::rotate_2d(const Point3D &c, float angle)
|
||||
{
|
||||
angle = PosUtil::deg2rad(angle) ;
|
||||
|
||||
float new_x = cos(angle) * (x-c.x) - sin(angle) * (y-c.y) + c.x ;
|
||||
float new_y = sin(angle) * (x-c.x) + cos(angle) * (y-c.y) + c.y ;
|
||||
|
||||
x = new_x ;
|
||||
y = new_y ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Operators *** */
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ public:
|
|||
const float radius) const ;
|
||||
/// Angle BÂC (A being *this) in 2D
|
||||
double angle_2d(const Point3D &b, const Point3D &c) const ;
|
||||
/// Rotate #x and #y with a given angle around a center c
|
||||
void rotate_2d(const Point3D ¢er, float angle) ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
|
Loading…
Reference in New Issue