don't understand how rotation is done
Posted by cantcode on Jun 07, 2013; 12:31pm
URL: https://forum.librecad.org/don-t-understand-how-rotation-is-done-tp5708244.html
in void RS_Ellipse::draw()
there is this line: auto&& ap1=getTangentDirection(vp).angle();
"RS_Vector RS_Ellipse::getTangentDirection(const RS_Vector& point) const" uses
RS_Vector RS_Vector::rotate(const RS_Vector& angleVector)
can someone please tell me what this method does?
I don't understand how a vector can be rotated by a vector.
"Rotates this vector around 0/0 by the given vector"
/**
* Rotates this vector around 0/0 by the given vector
* if the vector is a unit, then, it's the same as rotating around
* 0/0 by the angle of the vector
*/
RS_Vector RS_Vector::rotate(const RS_Vector& angleVector) {
// RS_DEBUG->print("RS_Vector::rotate: rotating Vecotr: %g/%g", x,y);
// RS_DEBUG->print("RS_Vector::rotate: rotating by Vecotr: %g/%g", angleVector.x,angleVector.y);
double x0 = x * angleVector.x - y * angleVector.y;
y = x * angleVector.y + y * angleVector.x;
x = x0;
// RS_DEBUG->print("RS_Vector::rotate: rotated x/y: %f/%f", x, y);
return *this;
}
btw. what does getEllipseAngle() return (which angle and which units? deg,rad,grad,...)
thought it just returns majorP.angle() but it seems like there is more done.
and in "auto&& ap1" is ap1 a reference of a reference???