25 o <<
"********" << std::endl;
26 o <<
"a_point:" << std::endl;
27 o <<
"********" << std::endl;
28 o <<
"This is a 3D 'point' or 'vector' class" << std::endl;
30 o <<
"Create a point:" << std::endl;
31 o <<
" a_point a" << std::endl;
32 o <<
" a_point b 1. 2.5 0." << std::endl;
34 o <<
"Commands:" << std::endl;
35 o <<
"+, -: add or subtract points." << std::endl;
36 o <<
"*: scalar product (or multiply by a scalar)." << std::endl;
37 o <<
"cross: cross product." << std::endl;
38 o <<
"/: divide by a scalar." << std::endl;
39 o <<
"x, y, z, x _x, y _y, z _z: get or set coordinates." << std::endl;
40 o <<
"set _x _y _z: set coordinates." << std::endl;
41 o <<
"set_cylindrical _r _phi _h: set coordinates (using cylindrical coordinate input)." << std::endl;
42 o <<
"set_spherical _r _theta _phi: set coordinates (using spherical coordinate input)." << std::endl;
43 o <<
"clear: set to (0,0,0)." << std::endl;
44 o <<
"translate _x _y _z: translate." << std::endl;
45 o <<
"rotate _xaxis _yaxis _zaxis: rotate." << std::endl;
46 o <<
"rotate _axis _angle: rotate around an axis of a given angle _angle." << std::endl;
47 o <<
"sumsq: sum of the square of the coordinates." << std::endl;
48 o <<
"norm: returns norm." << std::endl;
49 o <<
"normalise: normalise point." << std::endl;
50 o <<
"norm1: taxi cab norm." << std::endl;
51 o <<
"norm2: euclidian norm." << std::endl;
52 o <<
"normI: maximum norm." << std::endl;
53 o <<
"dist _pt: returns distance to _pt." << std::endl;
54 o <<
"max: set maximum abs value of component to 1." << std::endl;
55 o <<
"_pt1 angle _pt2: returns angle between 2 points." << std::endl;
56 o <<
"average _pt1 _pt2 _f: returns intermediate point; average coordinates; proportion is given by _f." << std::endl;
57 o <<
"average_rot _pt1 _pt2 _pos: returns intermediate point; average norm and average orientation; proportion is given by _f." << std::endl;
59 o <<
"Examples:" << std::endl;
60 o <<
" puts \"a: [a print]\"" << std::endl;
61 o <<
" puts \"a-b: [ [a - b ] print]\"" << std::endl;
62 o <<
" puts \"a*b: [ a * b]\"" << std::endl;
63 o <<
" puts \"||a||: [a norm]\"" << std::endl;
64 o <<
" a normalise" << std::endl;
65 o <<
" puts \"distance ab: [a dist b]\"" << std::endl;
66 o <<
"..." << std::endl;
136 return ((
x_ == p.
x())&&(
y_ == p.
y())&&(
z_ == p.
z()));
174 return fabs(
x_)+fabs(
y_)+fabs(
z_);
182 double max(fabs(
x_));
200 for (
short i=0; i<3; i++)
202 double xi = (*this)[i];
203 for (
short j=0; j<=i; j++)
205 double xj = (*this)[j];
216 double max = fabs(
x_);
227 double xn = (*this)*x_axis;
228 double yn = (*this)*y_axis;
229 double zn = (*this)*z_axis;
230 x_ = xn;
y_ = yn;
z_ = zn;
287 r.
x(a.
y()*b.
z()-a.
z()*b.
y());
288 r.
y(a.
z()*b.
x()-a.
x()*b.
z());
289 r.
z(a.
x()*b.
y()-a.
y()*b.
x());
303 double d = dpp.
norm();
304 double a1 = acos(n1*n2);
305 double a2 = acos(dpp*n2/d);
308 r = d*sin(a2)/sin(a1);
324 o << this->
x() <<
" ";
325 o << this->
y() <<
" ";
326 o << this->
z() <<
" ";
331 double pi = 3.141592653589793238;
354 double l1 = a.
norm();
355 double l2 = b.
norm();
356 double l = l1+f*(l2-l1);
358 double phi =
angle(a,b)*f;
a_point operator-(const a_point &a, const a_point &b)
a_point operator+(const a_point &a, const a_point &b)
double angle(a_point a, a_point b)
a_point cross(const a_point &a, const a_point &b)
a_point average_rot(const a_point &a, const a_point &b, double f)
a_point circle_centre(const a_point &p1, const a_point &p2, const a_point &p3)
a_point operator/(const a_point &a, double v)
double operator*(const a_point &a, const a_point &b)
a_quaternion sqrt(const a_quaternion &x)
static const std::string help()
a_point & operator-=(const a_point &)
a_point operator+(const a_point &)
a_point & operator+=(const a_point &)
a_point & operator=(const a_point &p)
bool operator==(const a_point &p) const
a_point & rotate(const a_point &x_axis, const a_point &y_axis, const a_point &z_axis)
a_point cross(const a_point &) const
static const std::string help()
a_point & operator/=(double v)
virtual void write(std::ostream &o) const
double operator*=(const a_point &)
double operator*(const a_point &)
virtual void read(std::istream &i)
a_point & max()
set maximum abs value of component to 1.