template<class T1, class T2>
rp_deg_to_xy<T1,T2> Function Reference
Transforms polar coordinates (r, (p)hi) to two-dimensional
Cartesian, or xy, coordinates.
Details...
#include <CoordSys.h>
Prototype
-
template <class T1, class T2>
void rp_deg_to_xy( const T1& rp_in,
T2& xy_out)
-
template <class T1, class T2>
void rp_deg_to_xy( const T1& r_in,
const T1& phi_in,T2& x_out,T2& y_out)
-
template <class T1, class T2>
void rp_deg_to_xy( const T1& rp_in,
const T2& xy_out)
-
template <class T1, class T2>
void rp_deg_to_xy( const T1& r_in,
const T1& phi_in, const T2& x_out,const T2& y_out)
Details
rp_deg_to_xy obtains the two-dimensional Cartesian, or xy, coordinates
from polar coordinates (r, (p)hi ), where:-
- phi is the angular distance in degrees from the positive
x axis, in range, [0,360); and,
- r is the magnitude of the radial distance.
See also: rp_to_xy,
xy_to_rp_deg.
Examples:
test_coordrep_trans.cc
Function Documentation
template <class T1, class T2>
void rp_deg_to_xy( const T1& rp_in,
T2& xy_out)
Transforms polar coordinates (r, (p)hi) to two-dimensional Cartesian,
or xy, coordinates.
rp_in is an indexable class where
- rp_in[0]=(r), and
- rp_in[1]=(p)hi.
Similarly,
- xy_out[0]=x, and
- xy_out[1]=y.
Calculates xy_out as:-
xy_out[0]=rp_in[0]*cos(rp_in[1]);
xy_out[1]=rp_in[0]*sin(rp_in[1]);
template <class T1, class T2>
void rp_deg_to_xy( const T1& r_in,
const T1& phi_in,T2& x_out,T2& y_out)
As above but with the exception that the individual coordinates are passed
as separate arguments, rather than as indexable classes.
template <class T1, class T2>
void rp_deg_to_xy( const T1& rp_in,
T2& xy_out)
const version of rp_deg_to_xy with indexable-class arguments.
This version is instantiated when xy_out is the result of an
operation passed-by-value (e.g. the result of a
Matrix<T> index operation.)
In these cases, xy_out acts as a handle on the actual data
storage area - xy_out cannot itself be modified, but the data it refers
to can be.
template <class T1, class T2>
void rp_deg_to_xy( const T1& r_in,
const T1& phi_in, const T2& x_out, const T2& y_out)
const version of rp_deg_to_xy with individual coordinates
being passed as the arguments. This version is instantiated when x_out
and y_out are both the results of operations passed-by-value.
Requirements on types
For all versions,
- <r_in(rp_in[0]) and phi_in(rp_in[1]) must be both be
instances of a class T1 for which the maths functions cos
and sin, and the multiply operator* are defined.
- xy_out(or, x_out, y_out) must be instances of a
class T2 which is convertible to, from an object of class T1.
In the first and third versions:-
- rp_in and xy_out must both be instances of classes
T1 and T2, for which the index operator[] must be
valid.
For the second and fourth const versions:-
- xy_out(or, x_out, y_out) must be instances of a
class T2 for which update operations are possible on const objects.
Preconditions
In the first and third versions,
- rp_in and xy_out must have at least two
elements, such that e.g. rp_in[1] and xy_out[1] are valid
operations.