亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? vector.h

?? 030_Particle_system using opengl
?? H
?? 第 1 頁 / 共 2 頁
字號:
#ifndef _VECTOR_H
#define _VECTOR_H
#include <math.h>

#ifndef PI180
#define PI180	0.0174532925199432957692369076848861f	// pi / 180
#endif

#ifndef PI
#define PI		3.1415926535897932384626433832795
#endif

#define MIN(x,y)		((x) < (y) ?  (x)      : (y))					// minimum
#define MAX(x,y)		((x) > (y) ?  (x)      : (y))					// maximum
#define ABS(x)			((x) < (0) ? -(x)      : (x))	

class vec2;
class vec4;

class vec  
{
public:
	union
	{
		struct
		{
			float x, y, z;
		};
		float v[3];
	};

	vec(){}
	inline vec( const vec &a);
	inline vec( const vec2 &a);
	inline vec( const vec4 &a);
	inline vec( const float a, const float b, const float c);
	inline void set( const float a, const float b, const float c);
	inline void clear();

	inline vec operator+() const;
	inline vec operator-() const;		// negative

	inline void operator+= ( const vec &a);
	inline void operator-= ( const vec &a);
	inline void operator*= ( const vec &a);
	inline void operator/= ( const vec &a);

	inline void operator+= ( const float f);
	inline void operator-= ( const float f);
	inline void operator*= ( const float f);
	inline void operator/= ( const float f);

	inline vec CROSS( const vec &a) const;
	inline float DOT3( const vec &a) const;
	inline float Length() const;
	inline float Length2() const;		// = Length ^ 2

	inline void RotX( const float angle);
	inline void RotY( const float angle);
	inline void RotZ( const float angle);
	
	inline void Normalize();
	inline void ArbitraryRotate(float theta, vec r);
/*
	inline friend vec operator+ ( const vec &a, const vec &b );
	inline friend vec operator- ( const vec &a, const vec &b );
	inline friend vec operator* ( const vec &a, const vec &b );
	inline friend vec operator/ ( const vec &a, const vec &b );

	inline friend vec operator+ ( const float f, const vec &a );
	inline friend vec operator- ( const float f, const vec &a );
	inline friend vec operator* ( const float f, const vec &a );
//	inline friend vec operator/ ( const float f, const vec &a );
	
	inline friend vec operator+ ( const vec &a, const float f );
	inline friend vec operator- ( const vec &a, const float f );
	inline friend vec operator* ( const vec &a, const float f );
	inline friend vec operator/ ( const vec &a, const float f );

	inline friend int operator< ( const vec &a, const vec &b );
	inline friend int operator<=( const vec &a, const vec &b );
	inline friend int operator> ( const vec &a, const vec &b );
	inline friend int operator>=( const vec &a, const vec &b );
	inline friend int operator==( const vec &a, const vec &b );
	inline friend int operator!=( const vec &a, const vec &b );

	inline friend vec CROSS ( const vec &a, const vec &b );
	inline friend float DOT3  ( const vec &a, const vec &b );
	inline friend vec Normalize( const vec &a );
	inline friend float Length( const vec &a );
	inline friend float Length2( const vec &a );
	inline friend float Distance ( const vec &a, const vec &b);
	inline friend float Distance2 ( const vec &a, const vec &b);
	inline friend vec MakeNormal( const vec &a, const vec &b, const vec &c);
	inline friend vec ReflectedRay( const vec &in, const vec &n);
	inline float PlaneDistance( const vec &normal, const vec &point);
	inline float PlanePointDelta( const vec &normal, float distance, const vec &point);
	inline float PlanePointDistance( const vec &normal, float distance, const vec &point);
	// Collision
	inline vec ClosestPointOnLine( const vec &a, const vec &b, const vec &point);
	inline int SpherePlaneCollision( const vec &center, float radius, const vec &normal, float distance, float *distanceCenterToPlane );
	double AngleBetweenVectors( const vec &a, const vec &b);
	inline int PointInsidePolygon( const vec &point, const vec &a, const vec &b, const vec &c);
	inline int PointInsidePolygon( const vec &point, const vec v[], unsigned int count);
	inline int EdgeSphereCollision( const vec &center, float radius, const vec &a, const vec &b, const vec &c);
	inline int EdgeSphereCollision( const vec &center, float radius, vec v[], unsigned int count);
	inline int SpherePolygonCollision(const vec &center, float radius, vec v[], unsigned int count, const vec &normal);
	inline int SpherePolygonCollision(const vec &center, float radius, const vec &a, const vec &b, const vec &c, const vec &normal);
	inline int LinePlaneCollision( const vec &a, const vec &b, const vec &normal, float distance);
	inline vec LinePlaneIntersection( const vec &a, const vec &b, const vec &normal, float distance);
	inline vec LinePlaneIntersectionDir( const vec &a, const vec &ab, const vec &normal, float distance);
	inline float LinePlaneIntersectionDirParameter( const vec &a, const vec &ab, const vec &normal, float distance);
	inline int LinePolygonCollision( const vec &a, const vec &b, vec v[], unsigned int count, const vec &normal);
	inline int LineSphereIntersection( const vec &p1, const vec &p2, const vec &center, float radius, double *t1, double *t2 );
	inline int LineSphereIntersectionDir( const vec &p1, const vec &p12, const vec &center, float radius, double *t1, double *t2 );
*/
};
inline char isInfPlus( const float &x);
inline char isInfMinus( const float &x);

inline vec::vec( const vec &a)
{	x = a.x; y = a.y; z = a.z;}
inline vec::vec( const float a, const float b, const float c )
{	x = a; y = b; z = c;}

inline void vec::set( const float a, const float b, const float c)
{	x = a; y = b; z = c;}

inline void vec::clear()
{	x = 0.f; y = 0.f; z = 0.f;}

inline vec vec::operator+() const	{	return *this;}
inline vec vec::operator-() const	{	return vec( -x, -y, -z);}

inline void vec::operator+= ( const vec &a){	x += a.x; y += a.y; z += a.z;}
inline void vec::operator-= ( const vec &a){	x -= a.x; y -= a.y; z -= a.z;}
inline void vec::operator*= ( const vec &a){	x *= a.x; y *= a.y; z *= a.z;}
inline void vec::operator/= ( const vec &a){	x /= a.x; y /= a.y; z /= a.z;}
inline void vec::operator+= ( const float f){	x += f; y += f; z += f; }
inline void vec::operator-= ( const float f){	x -= f; y -= f; z -= f; }
inline void vec::operator*= ( const float f){	x *= f; y *= f; z *= f; }
inline void vec::operator/= ( const float f){	x /= f; y /= f; z /= f; }

inline vec operator+ ( const vec &a, const vec &b ){return vec( a.x+b.x, a.y+b.y, a.z+b.z );}
inline vec operator- ( const vec &a, const vec &b ){return vec( a.x-b.x, a.y-b.y, a.z-b.z );}
inline vec operator* ( const vec &a, const vec &b ){return vec( a.x*b.x, a.y*b.y, a.z*b.z );}
inline vec operator/ ( const vec &a, const vec &b ){return vec( a.x/b.x, a.y/b.y, a.z/b.z );}

inline vec operator+ ( const float f, const vec &a ){return vec( f+a.x, f+a.y, f+a.z );}
inline vec operator- ( const float f, const vec &a ){return vec( f-a.x, f-a.y, f-a.z );}
inline vec operator* ( const float f, const vec &a ){return vec( f*a.x, f*a.y, f*a.z );}
inline vec operator+ ( const vec &a, const float f ){return vec( a.x+f, a.y+f, a.z+f );}
inline vec operator- ( const vec &a, const float f ){return vec( a.x-f, a.y-f, a.z-f );}
inline vec operator* ( const vec &a, const float f ){return vec( a.x*f, a.y*f, a.z*f );}
inline vec operator/ ( const vec &a, const float f ){float f_ = 1.0f/f;return vec( a.x*f_, a.y*f_, a.z*f_ );}

inline int operator< ( const vec &a, const vec &b ){return ((a.x< b.x)&&(a.y< b.y)&&(a.z< b.z));}
inline int operator<=( const vec &a, const vec &b ){return ((a.x<=b.x)&&(a.y<=b.y)&&(a.z<=b.z));}
inline int operator> ( const vec &a, const vec &b ){return ((a.x> b.x)&&(a.y> b.y)&&(a.z> b.z));}
inline int operator>=( const vec &a, const vec &b ){return ((a.x>=b.x)&&(a.y>=b.y)&&(a.z>=b.z));}
inline int operator==( const vec &a, const vec &b ){return ((a.x==b.x)&&(a.y==b.y)&&(a.z==b.z));}
inline int operator!=( const vec &a, const vec &b ){return ((a.x!=b.x)||(a.y!=b.y)||(a.z!=b.z));}

inline vec CROSS ( const vec &a, const vec &b )
{
	return vec( a.y*b.z - a.z*b.y,			//  i   j   k
				a.z*b.x - a.x*b.z,			// a.x a.y a.z
				a.x*b.y - a.y*b.x );		// b.x b.y b.z
}
inline vec vec::CROSS( const vec &a) const
{
	return vec( y*a.z - z*a.y,
				z*a.x - x*a.z,
				x*a.y - y*a.x );
}

inline float DOT3( const vec &a, const vec &b )
{
	return (a.x*b.x + a.y*b.y + a.z*b.z);
}
inline float vec::DOT3( const vec &a) const
{
	return (x*a.x + y*a.y +z*a.z);
}

inline float vec::Length() const
{	
	return (float) sqrt(x*x + y*y + z*z);
}

inline float vec::Length2() const
{	
	return (float) x*x + y*y + z*z;
}

inline void vec::RotX( const float angle)
{
	float s = (float) sin( PI180*angle );
	float c = (float) cos( PI180*angle );
	float Y=y;
	y =  y*c - z*s;
	z =  Y*s + z*c;
}
inline void vec::RotY( const float angle)
{
	float s = (float) sin( PI180*angle );
	float c = (float) cos( PI180*angle );
	float X=x;
	x =  x*c + z*s;
	z = -X*s + z*c;
}
inline void vec::RotZ( const float angle)
{
	float s = (float) sin( PI180*angle );
	float c = (float) cos( PI180*angle );
	float X=x;
	x =  x*c - y*s;
	y =  X*s + y*c;
}
inline void vec::Normalize()
{
	float length;

	length = (float) sqrt(x*x + y*y + z*z);
	if (length != 0) {
		x /= length;
		y /= length;
		z /= length;
	} else {
		x = 0;
		y = 0;
		z = 0;
	}
}

//	Rotate a vector by angle theta around an arbitrary axis r
//	Positive angles are anticlockwise looking down the axis  towards the origin.
inline void vec::ArbitraryRotate(float theta, vec r)	// Rotate a vector by angle theta around an arbitrary axis r
{
	vec p(x,y,z);
	float costheta,sintheta;

	theta*=PI180;
	r.Normalize();
	costheta = (float)cos(theta);
	sintheta = (float)sin(theta);

	x  = (costheta + (1 - costheta) * r.x * r.x) * p.x;
	x += ((1 - costheta) * r.x * r.y - r.z * sintheta) * p.y;
	x += ((1 - costheta) * r.x * r.z + r.y * sintheta) * p.z;

	y  = ((1 - costheta) * r.x * r.y + r.z * sintheta) * p.x;
	y += (costheta + (1 - costheta) * r.y * r.y) * p.y;
	y += ((1 - costheta) * r.y * r.z - r.x * sintheta) * p.z;

	z  = ((1 - costheta) * r.x * r.z - r.y * sintheta) * p.x;
	z += ((1 - costheta) * r.y * r.z + r.x * sintheta) * p.y;
	z += (costheta + (1 - costheta) * r.z * r.z) * p.z;
}

inline vec Normalize( const vec &a){	return a/a.Length();}
inline float Length( const vec &a ){	return a.Length();}
inline float Length2( const vec &a ){	return a.Length2();}
inline float Distance ( const vec &a, const vec &b){	return Length( a-b );}
inline float Distance2 ( const vec &a, const vec &b){	return Length2( a-b );}

inline vec MakeNormal( const vec &a, const vec &b, const vec &c)
{
	return Normalize(CROSS( b - a, c - a));
}

inline vec ReflectedRay( const vec &in, const vec &n)	// in from eye to vertex
{
	return (in - 2.f*n*DOT3( in, n));
}

inline float PlaneDistance( const vec &normal, const vec &point)
{
	return -DOT3( normal, point);	//	D = - Ax + By + Cz;   plane equation is Ax + By + Cz + D = 0
}
inline float PlanePointDelta( const vec &normal, float distance, const vec &point)
{
	// if point is on normal side, return positive value, else return negative value
	return DOT3( normal, point) + distance;			// d = Ax + By + Cz + D
}
inline float PlanePointDistance( const vec &normal, float distance, const vec &point)
{	
	// return always positive value
	return ABS(DOT3( normal, point) + distance);			// distance = ABS(Ax + By + Cz + D)
}

// najblisi bod na usecke a,b k bodu point
inline vec ClosestPointOnLine( const vec &a, const vec &b, const vec &point)
{
	vec ap = point - a;			// vector from a to point
	vec ab = b-a;				// vector from a to b
	float d = ab.Length();		// = Distance( a, b);  // length Line
	ab.Normalize();				// normalized direction vector from a to b
	float t = DOT3( ab, ap);	// ab is unit vector, t is distance from a to point projected on line ab
	if( t<= 0) return a;		// point projected on line ab is out of line, closest point on line is a
	if( t>= d) return b;		// point projected on line ab is out of line, closest point on line is b
	return a+t*ab;				// point away from a on t length in direction ab
}
inline int SpherePlaneCollision( const vec &center, float radius, const vec &normal, float distance, float *distanceCenterToPlane )
{
	*distanceCenterToPlane = DOT3( normal, center) + distance;			// d = Ax + By + Cz + D
	if( fabs(*distanceCenterToPlane) < radius) return 1;	// sphere intersected plane
//	if( *distanceCenterToPlane<= -radius) return 2;			// sphere behind plane
//	else return 0;											// sphere is front plane
	return 0;												// sphere is front or behind plane
}

inline double AngleBetweenVectors( const vec &a, const vec &b)
{							
	double angle = acos( DOT3( a, b) / ( a.Length()*b.Length() ) );
//	if(_isnan(angle))return 0;		// Here we make sure that the angle is not a -1.#IND0000000 number, which means indefinate
	if( isInfPlus( (float)angle)||isInfMinus( (float)angle) )return 0;
	return( angle );
}

// return, t=0 a, t=1 b
inline vec Interpolate( vec a, const vec &b, float t)
{
	if(a==b)return a;
	float angle = (float)AngleBetweenVectors( a, b);
	a.ArbitraryRotate( angle*t/PI180, CROSS( a, b));
	return a;
}

inline int PointInsidePolygon( const vec &point, const vec &a, const vec &b, const vec &c)
{
	vec pa = a-point;
	vec pb = b-point;
	vec pc = c-point;
	double angle  = AngleBetweenVectors( pa, pb);
	angle += AngleBetweenVectors( pb, pc);
	angle += AngleBetweenVectors( pc, pa);

	const double MATCH_FACTOR = 0.99;			// Used to cover up the error in floating point
	if(angle >= (MATCH_FACTOR * (2.0 * PI)) )	// If the angle is greater than 2 PI, (360 degrees)
		return 1;							// The point is inside of the polygon
	return 0;								// If you get here, it obviously wasn't inside the polygon, so Return FALSE
}

inline int PointInsidePolygon( const vec &point, const vec v[], unsigned int count)
{
	double angle = 0.0;
	
	for (int i = 0; (unsigned int)i<count; i++)				// Go in a circle to each vertex and get the angle between
		angle += AngleBetweenVectors( v[i] - point, v[(i+1)%count] - point);
											
	const double MATCH_FACTOR = 0.99;			// Used to cover up the error in floating point
	if(angle >= (MATCH_FACTOR * (2.0 * PI)) )	// If the angle is greater than 2 PI, (360 degrees)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
26uuu亚洲婷婷狠狠天堂| 精品免费视频.| 精品美女被调教视频大全网站| 亚洲18女电影在线观看| 91小视频在线免费看| 精品国产一区二区三区久久久蜜月| 亚洲久草在线视频| 国产福利一区二区三区视频| 91精品国产综合久久久蜜臀图片| 一区二区三区资源| 91免费观看在线| 亚洲综合免费观看高清在线观看 | 亚洲激情一二三区| 中文字幕在线一区免费| 欧美亚洲国产bt| 国产亚洲精品资源在线26u| 亚洲va欧美va国产va天堂影院| 欧美久久一二区| 亚洲一区在线观看免费观看电影高清| 欧美精品一二三四| 国产一区美女在线| 亚洲精品一区二区三区在线观看| 国产成人av影院| 亚洲自拍偷拍欧美| 亚洲精品一线二线三线无人区| 91麻豆成人久久精品二区三区| 亚洲精品v日韩精品| 在线看国产一区| 亚洲综合成人在线| 精品国产一区二区三区av性色 | 美国精品在线观看| 日韩一级免费观看| 裸体歌舞表演一区二区| 日韩欧美一区在线观看| 99久久精品国产导航| 亚洲精品你懂的| 精品久久久久久久久久久久久久久| 91最新地址在线播放| 国产综合色视频| 欧美国产精品久久| 不卡视频在线观看| 亚洲综合在线视频| 国产亚洲精品超碰| 欧美一级二级三级乱码| 日本道免费精品一区二区三区| 一区二区三区国产豹纹内裤在线| 精品国产露脸精彩对白| 在线观看免费一区| 99久久精品一区二区| 精品一区二区三区av| 国产精品久久久久久久久搜平片 | 日韩一区二区三区在线视频| 91网上在线视频| 粉嫩av亚洲一区二区图片| 亚洲精选一二三| 国产亚洲欧美在线| 欧美电影免费观看高清完整版在线观看 | 欧美国产精品专区| 欧美精品一区视频| 欧美一区二区三区视频在线观看| 国产一区二区调教| 婷婷夜色潮精品综合在线| 国产欧美视频在线观看| 欧洲精品一区二区| 91农村精品一区二区在线| 国产在线精品不卡| 久久国产婷婷国产香蕉| 青青草97国产精品免费观看 | 久久看人人爽人人| 欧美综合一区二区| 色婷婷精品久久二区二区蜜臂av| 久久电影网电视剧免费观看| 午夜伊人狠狠久久| 天天综合色天天综合色h| 亚洲aaa精品| 日韩电影在线观看电影| 亚洲人成网站色在线观看| 日韩欧美高清在线| 日韩一二三区视频| 精品蜜桃在线看| 国产亚洲精品福利| 中文字幕在线观看不卡视频| 精品伦理精品一区| 久久这里只有精品6| 国产欧美一区在线| 国产精品毛片无遮挡高清| 欧美精品一区二区三| 久久综合九色综合97_久久久| 26uuu成人网一区二区三区| 久久蜜桃av一区二区天堂| 欧美激情在线观看视频免费| 18涩涩午夜精品.www| 一区二区三区日韩精品视频| 香蕉久久夜色精品国产使用方法| 麻豆精品一区二区综合av| 高清在线成人网| 欧美专区亚洲专区| 精品精品国产高清一毛片一天堂| 国产亚洲一区二区三区在线观看| 国产精品视频一区二区三区不卡| 亚洲美女淫视频| 青青草97国产精品免费观看| 国产1区2区3区精品美女| 99精品视频在线播放观看| 欧美视频精品在线观看| 26uuu成人网一区二区三区| 中文字幕亚洲精品在线观看| 午夜影院在线观看欧美| 国产美女视频一区| 欧美视频精品在线观看| 久久精品人人做人人爽人人| 一区二区三区四区av| 久久av中文字幕片| 99精品1区2区| 精品少妇一区二区三区 | 欧美日本乱大交xxxxx| 精品视频色一区| 欧美日韩国产综合久久| 日韩欧美中文一区| 亚洲免费大片在线观看| 久久精品国产**网站演员| 97久久超碰精品国产| 日韩一级片在线观看| 国产精品国产三级国产普通话蜜臀 | 97精品久久久午夜一区二区三区| 在线不卡中文字幕| 亚洲欧洲国产专区| 精品一区二区三区视频| 日本伦理一区二区| 国产亚洲短视频| 日本sm残虐另类| 99国产一区二区三精品乱码| www成人在线观看| 亚洲成人在线观看视频| 99国产精品久久久| 国产性天天综合网| 美女在线一区二区| 欧美日韩高清一区| 亚洲女同ⅹxx女同tv| 国产精品一区专区| 99久久夜色精品国产网站| 日韩欧美aaaaaa| 丝袜亚洲精品中文字幕一区| 狠狠色狠狠色综合日日91app| 欧美在线观看禁18| 自拍偷拍亚洲欧美日韩| 日本最新不卡在线| 欧美日韩美少妇| 综合激情成人伊人| 99这里只有久久精品视频| 欧美猛男超大videosgay| 亚洲色图19p| 99re6这里只有精品视频在线观看| 国产日产欧产精品推荐色| 精品一区二区在线观看| 欧美一区二区福利视频| 天堂久久久久va久久久久| 在线国产电影不卡| 亚洲一区二三区| 色94色欧美sute亚洲线路一ni| 亚洲精品老司机| 色999日韩国产欧美一区二区| 亚洲免费在线视频一区 二区| 91香蕉视频污| 亚洲精品视频一区| 91官网在线观看| 亚洲一区二区三区中文字幕在线| 欧美综合天天夜夜久久| 亚洲一区日韩精品中文字幕| 欧美三级日韩在线| 日韩精品一二区| 日韩欧美成人一区二区| 韩国三级在线一区| 国产欧美日韩在线视频| 国产精品69久久久久水密桃| 欧美国产一区二区| av激情综合网| 亚洲一区二区在线视频| 91精品中文字幕一区二区三区| 琪琪久久久久日韩精品| 精品少妇一区二区三区在线播放| 国产精品一区二区三区网站| 国产精品美女久久久久久久网站| 色偷偷久久一区二区三区| 亚洲一区二区三区免费视频| 日韩一级欧美一级| 国产91高潮流白浆在线麻豆| 亚洲欧美日本在线| 欧美精品乱码久久久久久| 久久国产精品99久久人人澡| 国产色婷婷亚洲99精品小说| 99精品视频在线观看免费| 五月天欧美精品| 久久久亚洲欧洲日产国码αv| 成人免费毛片app| 欧美国产在线观看| 精品视频免费在线| 国产成人一区在线| 亚洲国产视频网站| 欧美人伦禁忌dvd放荡欲情|