46 a_point v = cross(
d,u);
48 a_point ppn=(u*cos(
r)+v*sin(
r))*spp;
57 void a_twist::set(
double x,
double y,
double z,
double dx,
double dy,
double dz,
double t,
double r)
70 a_twist::a_twist(
double x,
double y,
double z,
double dx,
double dy,
double dz,
double t,
double r)
98 a_point pl = ar*(ar*p);
100 double lpr = pr.norm();
104 a_point prx = pr/lpr;
105 a_point pry = cross(ar,pr).normalise();
108 a_point prn = prx+pry;
114 std::ostringstream o;
115 o <<
"*********" << std::endl;
116 o <<
"a_twist:" << std::endl;
117 o <<
"*********" << std::endl;
118 o <<
"This class is used to model a twist: rotation + translation" << std::endl;
119 o <<
"Commands:" << std::endl;
120 o <<
"--------" << std::endl;
121 o <<
"a_twist T: creates the identity twist" << std::endl;
122 o <<
"a_twist T 'p' 'd' 't' 'r': creates a twist applied at 'p', translating 't' and rotating of angle 'r' along direction 'd'" << std::endl;
123 o <<
"a_twist T 'x' 'y' 'z' 'dx' 'dy' 'dz' ('r'): creates a twist applied at 'x,y,z', translating 'dx,dy,dz' while, possibly, rotating of angle 'r'" << std::endl;
124 o <<
"" << std::endl;
125 o <<
"set 'p' 'd' 't' 'r': set twist applied at 'p', translating 't' and rotating of angle 'r' along direction 'd'" << std::endl;
126 o <<
"set 'x' 'y' 'z' 'dx' 'dy' 'dz' ('r'): set twist applied at 'x,y,z', translating 'dx,dy,dz' while, possibly, rotating of angle 'r'" << std::endl;
127 o <<
"reset: reset to an identity twist" << std::endl;
128 o <<
"dx: gets translation along x" << std::endl;
129 o <<
"dy: gets translation along y" << std::endl;
130 o <<
"dz: gets translation along z" << std::endl;
131 o <<
"d: gets translation norm" << std::endl;
132 o <<
"rx: gets rotation about x" << std::endl;
133 o <<
"ry: gets rotation about y" << std::endl;
134 o <<
"rz: gets rotation about z" << std::endl;
135 o <<
"r: gets rotation norm" << std::endl;
136 o <<
"quaternion: gets quaternion of transformation (a_quaternion)" << std::endl;
137 o <<
"matrix: gets matrix of transformation (a_mat_sq)" << std::endl;
138 o <<
"translate 'p': translates of 'p'" << std::endl;
139 o <<
"translate 'x' 'y' 'z': idem" << std::endl;
140 o <<
"rotate 'p' 'dir' 'v': rotate of an angle 'v' around an axe of rotation passing by 'p' and with direction 'dir'" << std::endl;
141 o <<
"'twist' * 'p': gets a new point, transforming point 'p' using the twist 'twist'" << std::endl;
158 a_point n = this->
p1();
161 double c = cos(
r/2.);
162 double s = sin(
r/2.);
163 a_quaternion q(c,n.x()*s,n.y()*s,n.z()*s);
169 a_point n(q.i(),q.j(),q.k());
174 double r = 2*acos(a);
181 a_point n = this->
p1();
190 m(0,0) = x*x*cc+c; m(0,1) = y*x*cc-z*s; m(0,2) = z*x*cc+y*s;
191 m(1,0) = x*y*cc+z*s; m(1,1) = y*y*cc+c; m(1,2) = z*y*cc-x*s;
192 m(2,0) = x*z*cc-y*s; m(2,1) = y*z*cc+x*s; m(2,2) = z*z*cc+c;
200 double r = acos((mat(0,0)+mat(1,1)+mat(2,2)-1)/2.);
201 double x = mat(2,1)-mat(1,2);
202 double y = mat(0,2)-mat(2,0);
203 double z = mat(1,0)-mat(0,1);
217 a_quaternion q3 = q2*q1;
221 a_quaternion q4(0.,dp.x(),dp.y(),dp.z());
222 a_quaternion q2i = q2;
224 a_quaternion q5 = q2*q4*q2i;
225 p2_.x(pt.x()-q5.i());
226 p2_.y(pt.y()-q5.j());
227 p2_.z(pt.z()-q5.k());
a_point operator*(a_point p, const a_twist &t)
a_point operator*(a_point p) const
transform a point using the screw
a_quaternion quaternion() const
conversion routines
void rotate(const a_point &pt, const a_point &dir, double v)
void set(const a_point &p, a_point d, double t, double r)
void translate(const a_point &d)
iterative transformation
double dx() const
p2_ : translation
static const std::string help()
get information about the class