📄 ivu_linear.hxx
字号:
// Copyright (C) Ipion Software GmbH 1999-2000. All rights reserved.
//IVP_EXPORT_PUBLIC
#ifndef _IVP_U_LINEAR_INCLUDED
#define _IVP_U_LINEAR_INCLUDED
#ifdef IVP_WINDOWS_ALIGN16
#pragma pack(push,16)
#endif
#ifdef WIN32
# pragma warning( disable : 4244 )
#endif
#ifndef WIN32
# pragma interface
#endif
class IVP_U_Straight;
class IVP_U_Hesse;
class IVP_U_Quat;
class IVP_U_Point;
class IVP_U_Float_Quat;
/********************************************************************************
* Name: IVP_COORDINATE_INDEX
* Description: Use these enums everywhere where you want to specify a coodinate.
********************************************************************************/
enum IVP_COORDINATE_INDEX {
IVP_INDEX_X = 0, // you can rely on these
IVP_INDEX_Y = 1, // numbers - they will
IVP_INDEX_Z = 2 // never be changed.
};
/********************************************************************************
* Name: IVP_U_Float_Point
* Description: A float triple used for various purposes.
********************************************************************************/
class IVP_U_Float_Point3 {
public:
IVP_FLOAT k[3];
inline void set(const IVP_FLOAT p[3]);
#if !defined(IVP_NO_DOUBLE)
inline void set(const IVP_DOUBLE p[3]);
#endif
inline void byte_swap() { ivp_byte_swap4( (uint&) k[0] );
ivp_byte_swap4( (uint&) k[1] );
ivp_byte_swap4( (uint&) k[2] ); }
};
class IVP_U_Float_Point {
public:
IVP_FLOAT k[3];
#ifdef IVP_VECTOR_UNIT_FLOAT
union {
IVP_FLOAT hesse_val;
};
#endif
#if !defined(IVP_NO_DOUBLE)
inline void set(const IVP_U_Point *p);
#endif
inline void set(const IVP_FLOAT p[3]);
inline void set(const IVP_U_Float_Point *p);
inline void set(IVP_FLOAT k0, IVP_FLOAT k1, IVP_FLOAT k2);
inline void set_negative(const IVP_U_Float_Point *p_source); // this = p_source * -1.0
inline void set_to_zero(); // i.e. set(0.0, 0.0, 0.0)
inline IVP_DOUBLE quad_length()const; // length of vector square: k[0]*k[0] + k[1]*k[1] + k[2]*k[2]
inline void mult(IVP_DOUBLE factor); // this *= factor
inline void add(const IVP_U_Float_Point *v2); // this += v2
inline void add(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this = v1 + v2;
inline void add_multiple(const IVP_U_Float_Point *v, IVP_DOUBLE factor); // this += v1 * factor
inline void add_multiple(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2, IVP_DOUBLE factor2);
inline void set_multiple(const IVP_U_Quat *q_source,IVP_DOUBLE f); // this = q_source.xyz * f
#if !defined(IVP_NO_DOUBLE)
inline void set_multiple(const IVP_U_Point *v,IVP_DOUBLE f); // this = q_source.xyz * f
#endif
inline void set_multiple(const IVP_U_Float_Point *v,IVP_DOUBLE f); // this = q_source.xyz * f
inline void set_pairwise_mult(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this->k[i] = v1->k[i] * v2->k[i]
#if !defined(IVP_NO_DOUBLE)
inline void subtract(const IVP_U_Point *v1, const IVP_U_Point *v2); // this = v1 - v2
#endif
inline void subtract(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this = v1 - v2
inline void subtract(const IVP_U_Float_Point *v2); // this = this - v2;
inline void inline_subtract_and_mult(const IVP_U_Float_Point *v1,const IVP_U_Float_Point *v2, IVP_DOUBLE factor); // this = (v1-v2) * factor
#if !defined(IVP_NO_DOUBLE)
inline void inline_subtract_and_mult(const IVP_U_Point *v1,const IVP_U_Point *v2, IVP_DOUBLE factor); // this = (v1-v2) * factor
#endif
inline IVP_DOUBLE dot_product(const IVP_U_Float_Point *v2) const;
inline void inline_calc_cross_product(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this = v1 x v2
inline void inline_calc_cross_product_and_normize(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this = v1 x v2
inline void inline_set_vert_to_area_defined_by_three_points(const IVP_U_Float_Point *tp0,const IVP_U_Float_Point *tp1,const IVP_U_Float_Point *tp2);
void calc_cross_product(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this = v1 x v2
void line_sqrt(); // Sqrt of each element: k[i] = sqrt(k[i])
void set_interpolate(const IVP_U_Float_Point *p0,const IVP_U_Float_Point *p1, IVP_DOUBLE s);
void set_orthogonal_part(const IVP_U_Float_Point *vector,const IVP_U_Float_Point *normal_v); //project vector on surface given by normal_v
void rotate(IVP_COORDINATE_INDEX axis, IVP_FLOAT angle); // rotate the point around origin
IVP_DOUBLE real_length()const; // real length = sqrt(quad_length)
IVP_DOUBLE fast_real_length()const; // real length with 0.1f% error, really fast
IVP_DOUBLE real_length_plus_normize(); // Normize vector and return former real length.
inline IVP_DOUBLE quad_distance_to(const IVP_U_Float_Point *p)const; // quad distance from this point to another
IVP_RETURN_TYPE normize(); // normize vector (-> real_length == 1.0f)
IVP_RETURN_TYPE fast_normize(); // normize vector (0.1f% error)
void print(const char *comment = 0) const;
IVP_U_Float_Point(){;};
IVP_U_Float_Point(IVP_DOUBLE x, IVP_DOUBLE y,IVP_DOUBLE z){ k[0] = (IVP_FLOAT)x; k[1] = (IVP_FLOAT)y; k[2] = (IVP_FLOAT)z;};
IVP_U_Float_Point(const IVP_U_Float_Point *p);
#if !defined(IVP_NO_DOUBLE)
IVP_U_Float_Point(const IVP_U_Point *p);
#endif
inline void byte_swap() { ivp_byte_swap4( (uint&) k[0] );
ivp_byte_swap4( (uint&) k[1] );
ivp_byte_swap4( (uint&) k[2] );
#ifdef IVP_VECTOR_UNIT_FLOAT
ivp_byte_swap4( (uint&) hesse_val );
#endif
}
} IVP_ALIGN_16;
/********************************************************************************
* Name: IVP_U_Point
* Description: A double triple used for various purposes.
* Note: Some functions change 'this', other functions change
* parameters (check the const attribute).
* The inline implementation can be found in ivu_linear_macros.hxx
* and ivu_matrix_macros.hxx
* Performance Notes: All functions are optimized (on an assembler basis) to
* run best on Pentium and Pentium II CPU.
********************************************************************************/
#if defined(IVP_NO_DOUBLE)
class IVP_U_Point: public IVP_U_Float_Point {
public:
#else
class IVP_U_Point {
public:
IVP_DOUBLE k[3];
# ifdef IVP_VECTOR_UNIT_DOUBLE
union {
IVP_DOUBLE hesse_val;
};
# endif
inline IVP_DOUBLE dot_product(const IVP_U_Point *v2) const { return( k[0]*v2->k[0] + k[1]*v2->k[1] + k[2]*v2->k[2] ); };
inline IVP_DOUBLE dot_product(const IVP_U_Float_Point *v2) const { return( k[0]*v2->k[0] + k[1]*v2->k[1] + k[2]*v2->k[2] ); };
inline void inline_calc_cross_product(const IVP_U_Point *v1, const IVP_U_Point *v2); // this = v1 x v2
inline void inline_calc_cross_product_and_normize(const IVP_U_Point *v1, const IVP_U_Point *v2); // this = v1 x v2
void calc_cross_product(const IVP_U_Point *v1, const IVP_U_Point *v2); // this = v1 x v2
inline void set_to_zero(); // == set(0.0, 0.0, 0.0)
inline void set(const IVP_U_Point *p_source); // this = p_source
inline void set(const IVP_U_Float_Point *p_source); // this = (IVP_DOUBLE)p_source
inline void set(const IVP_U_Quat *q_source); // this = q_source.xyz
inline void set(IVP_DOUBLE k0, IVP_DOUBLE k1, IVP_DOUBLE k2 = 0.0f);
inline void set(const IVP_FLOAT p[3]);
inline IVP_DOUBLE quad_length()const; // Square length of vector: k[0]*k[0] + k[1]*k[1] + k[2]*k[2].
inline IVP_DOUBLE quad_distance_to(const IVP_U_Point *p)const; // Square distance from this point to another
inline IVP_DOUBLE quad_distance_to(const IVP_U_Float_Point *p)const; // Square distance from this point to another.
IVP_DOUBLE real_length()const; // Returns real length (= sqrt(quad_length)).
IVP_DOUBLE real_length_plus_normize(); // Normize vector and return former real length.
IVP_DOUBLE fast_real_length()const; // Returns real length with max. 0.1f% error, really fast if in cache.
IVP_RETURN_TYPE normize(); // Normize vector (-> real length == 1.0f), return IVP_FALSE if length too small.
IVP_RETURN_TYPE fast_normize(); // Normize vector (0.1f% error)
inline void add(const IVP_U_Point *v2); // this = this + v2;
inline void add(const IVP_U_Float_Point *v2); // this = this + v2;
inline void add(const IVP_U_Point *v1, const IVP_U_Point *v2); // this = v1 + v2;
inline void add(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this = v1 + v2;
inline void add_multiple(const IVP_U_Point *v, IVP_DOUBLE factor); // this += v1 * factor
inline void add_multiple(const IVP_U_Float_Point *v, IVP_DOUBLE factor); // this += v1 * factor
inline void add_multiple(const IVP_U_Point *v1, const IVP_U_Point *v2, IVP_DOUBLE factor2); // this = v1 + factor2*v2 .
inline void add_multiple(const IVP_U_Point *v1, const IVP_U_Float_Point *v2, IVP_DOUBLE factor2); // this = v1 + factor2*v2 .
inline void subtract(const IVP_U_Point *v2); // this = this - v2;
inline void subtract(const IVP_U_Float_Point *v2); // this = this - v2;
inline void subtract(const IVP_U_Point *v1,const IVP_U_Point *v2); // this = v1 - v2;
inline void subtract(const IVP_U_Float_Point *v1, const IVP_U_Float_Point *v2); // this = v1 - v2;
inline void subtract(const IVP_U_Float_Point *v1, const IVP_U_Point *v2); // this = v1 - v2;
inline void subtract(const IVP_U_Point *v1, const IVP_U_Float_Point *v2); // this = v1 - v2;
inline void inline_subtract_and_mult(const IVP_U_Point *v1,const IVP_U_Point *v2, IVP_DOUBLE factor); // this = (v1-v2) * factor
inline void inline_subtract_and_mult(const IVP_U_Float_Point *v1,const IVP_U_Float_Point *v2, IVP_DOUBLE factor); // this = (v1-v2) * factor
inline void set_negative(const IVP_U_Point *p_source); // this = p_source * -1.0
inline void mult(IVP_DOUBLE factor); // this *= factor
inline void set_multiple(const IVP_U_Point *p,IVP_DOUBLE f); // this = p * f
inline void set_multiple(const IVP_U_Float_Point *p,IVP_DOUBLE f); // this = p * f
inline void set_multiple(const IVP_U_Quat *q_source,IVP_DOUBLE f); // this = q_source.xyz * f
inline void set_pairwise_mult(const IVP_U_Point *v1, const IVP_U_Point *v2); // this->k[i] = v1->k[i] * v2->k[i]
inline void set_pairwise_mult(const IVP_U_Point *v1, const IVP_U_Float_Point *v2); // this->k[i] = v1->k[i] * v2->k[i]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -