1 #ifndef GeometryVector_newBasic2DVector_h 2 #define GeometryVector_newBasic2DVector_h 39 template <
class Other>
59 T x()
const {
return v[0]; }
62 T y()
const {
return v[1]; }
85 return my_mag == 0 ? *this : *
this / my_mag;
153 std::ostream&
print2D(std::ostream&
s,
double x,
double y);
159 inline std::ostream& operator<<(std::ostream& s, const Basic2DVector<T>&
v) {
173 template <
class T,
class U>
177 return RT(
a) + RT(
b);
180 template <
class T,
class U>
184 return RT(
a) - RT(
b);
194 template <
class T,
class U>
213 template <
class T,
class Scalar>
215 T t =
static_cast<T>(
s);
220 template <
class T,
class Scalar>
222 T t =
static_cast<T>(
s);
234 template <
class T,
class Scalar>
237 T t =
static_cast<T>(
s);
244 #endif // GeometryVector_Basic2DVector_h
Basic2DVector(const T &x, const T &y)
construct from cartesian coordinates
auto cross2(V1 x, V2 y) -> typename std::remove_reference< decltype(x[0])>::type
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Basic2DVector(Vec2< U > const &iv)
MathVector const & mathVector() const
Basic2DVector(const Basic2DVector &p)
Copy constructor from same type. Should not be needed but for gcc bug 12685.
Basic2DVector(Vec4< U > const &iv)
Basic2DVector< T > operator+(const Basic2DVector< T > &a, const Basic2DVector< T > &b)
vector sum and subtraction of vectors of possibly different precision
T y() const
Cartesian y coordinate.
Basic2DVector(const Basic2DVector< U > &p)
Basic2DVector(const Other &p)
Basic2DVector< double > Basic2DVectorD
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
Basic2DVector< T > operator-(const Basic2DVector< T > &a, const Basic2DVector< T > &b)
Basic2DVector< float > Basic2DVectorF
Geom::Phi< T > phi() const
Geom::Polar2Cartesian< T > Polar
T operator*(const Basic2DVector< T > &v1, const Basic2DVector< T > &v2)
T cross(const Basic2DVector &lh) const
Vector product, or "cross" product, with a vector of same type.
Basic2DVector & operator*=(T t)
Scaling by a scalar value (multiplication)
PreciseFloatType< T, U >::Type cross(const Basic2DVector< U > &lh) const
Basic2DVector & operator/=(T t)
Scaling by a scalar value (division)
std::ostream & print2D(std::ostream &s, double x, double y)
Basic2DVector(MathVector const &iv)
Basic2DVector unit() const
Basic2DVector & operator+=(const Basic2DVector< U > &p)
Basic2DVector< T > operator/(const Basic2DVector< T > &v, T t)
MathVector & mathVector()
Basic2DVector operator-() const
Unary minus, returns a vector with components (-x(),-y(),-z())
T r() const
Radius, same as mag()
Basic2DVector & operator-=(const Basic2DVector< U > &p)
T dot(const Basic2DVector &lh) const
Scalar product, or "dot" product, with a vector of same type.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T x() const
Cartesian x coordinate.
PreciseFloatType< T, U >::Type dot(const Basic2DVector< U > &lh) const
T operator[](int i) const