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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? vector.h

?? 030_Particle_system using opengl
?? H
?? 第 1 頁 / 共 2 頁
字號(hào):
		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 EdgeSphereCollision( const vec &center, float radius, const vec &a, const vec &b, const vec &c)
{
	if( Distance(center, ClosestPointOnLine( a, b, center)) < radius) return 1;
	if( Distance(center, ClosestPointOnLine( b, c, center)) < radius) return 1;
	if( Distance(center, ClosestPointOnLine( c, a, center)) < radius) return 1;
	return 0;
}

inline int EdgeSphereCollision( const vec &center, float radius, vec v[], unsigned int count)
{
	for(int i = 0; (unsigned int)i<count; i++)
		if( Distance(center, ClosestPointOnLine(v[i], v[(i+1)%count], center)) < radius) return 1;
	return 0;
}

inline int SpherePolygonCollision(const vec &center, float radius, vec v[], unsigned int count, const vec &normal)
{
	float distance = PlaneDistance( normal, v[0] );
	float distanceCenterToPlane;

	if(SpherePlaneCollision( center, radius, normal, distance, &distanceCenterToPlane) == 1) 
	{
		vec centerProjOnPlane = center - distanceCenterToPlane*normal;			// center project on plane

		if( PointInsidePolygon( centerProjOnPlane, v, count ) ||
			EdgeSphereCollision( center, radius, v, count ) )
		{
			return 1;
		}
	}
	return 0;
}

inline int SpherePolygonCollision(const vec &center, float radius, const vec &a, const vec &b, const vec &c, const vec &normal)
{
	float distance = PlaneDistance( normal, a );
	float distanceCenterToPlane;

	if(SpherePlaneCollision( center, radius, normal, distance, &distanceCenterToPlane) == 1) 
	{
		vec centerProjOnPlane = center - distanceCenterToPlane*normal;			// center project on plane

		if( PointInsidePolygon( centerProjOnPlane, a, b, c )  ||
			EdgeSphereCollision( center, radius, a, b, c ) )
		{
			return 1;
		}
	}
	return 0;
}

inline int SpherePolygonCollisionRadius05(const vec &center, float radius, const vec &a, const vec &b, const vec &c, const vec &normal)
{
	float distance = PlaneDistance( normal, a );
	float distanceCenterToPlane;

	if(SpherePlaneCollision( center, radius, normal, distance, &distanceCenterToPlane) == 1) 
	{
		vec centerProjOnPlane = center - distanceCenterToPlane*normal;			// center project on plane

		if( PointInsidePolygon( centerProjOnPlane, a, b, c )  ||
			EdgeSphereCollision( center, 0.5f*radius, a, b, c ) )
		{
			return 1;
		}
	}
	return 0;
}

inline int LinePlaneCollision( const vec &a, const vec &b, const vec &normal, float distance)
{
	float distance_a_plane = DOT3( normal, a) + distance;
	float distance_b_plane = DOT3( normal, b) + distance;
	if( distance_a_plane*distance_b_plane < 0) return 1;	// must have differently sign
	return 0;
}

inline vec LinePlaneIntersectionDir( const vec &a, const vec &ab, const vec &normal, float distance)
{
	vec ab_norm = Normalize( ab);
	float distance_plane_a = DOT3( normal, a) + distance;
	float divisor = DOT3( normal, ab_norm);
	if(divisor==0.f) return a;				// line lie on plane
	float t = distance_plane_a/divisor;
	return a-t*ab_norm;
}

inline float LinePlaneIntersectionDirParameter( const vec &a, const vec &ab, const vec &normal, float distance)
{
	vec ab_norm = Normalize( ab);
	float distance_plane_a = DOT3( normal, a) + distance;
	float divisor = DOT3( normal, ab_norm);
	if(divisor==0.f) return 0.f;				// line lie on plane
	float t = distance_plane_a/divisor;
	return -t/ab.Length();						// for point a t=0, for a+ab t=1.0f 
}

inline vec LinePlaneIntersection( const vec &a, const vec &b, const vec &normal, float distance)
{
	return LinePlaneIntersectionDir( a, b-a, normal, distance );
}

inline int LinePolygonCollision( const vec &a, const vec &b, vec v[], unsigned int count, const vec &normal)
{
	float distance = PlaneDistance( normal, v[0]);
	if( !LinePlaneCollision( a, b, normal, distance) ) return 0;

	vec Intersection = LinePlaneIntersection( a, b, normal, distance);
	if( PointInsidePolygon( Intersection, v, count) ) return 1;
	return 0;
}

inline int LineSphereIntersectionDir( const vec &p1, const vec &p12, const vec &center, float radius, double *t1, double *t2 )
{
//	vec	p12 = p2-p1;
	double a = DOT3(p12, p12);		// a is always positive
	double b = 2.0*DOT3( p12, p1 - center);
	double c = DOT3( center, center) + DOT3( p1, p1) - 2.0*DOT3( center, p1) - radius*radius;
	double diskriminant = b*b - 4.0*a*c;

	if(diskriminant<0 || a==0){	*t1 = 0;*t2 = 0;return 0;}
	if(diskriminant==0)
	{
		*t1 = ( -b/(2.0*a) );
		*t2 = *t1;
		return 1;
	}
	double s_diskriminant = sqrt(diskriminant);
	*t1 = ( (-b + s_diskriminant)/(2.0*a) );
	*t2 = ( (-b - s_diskriminant)/(2.0*a) );
	// because a is always positive, t1 > t2
	return 2;
}

inline int LineSphereIntersection( const vec &p1, const vec &p2, const vec &center, float radius, double *t1, double *t2 )
{
	return LineSphereIntersectionDir( p1, p2-p1, center, radius, t1, t2);
}
/*  angle1
   in\  A n-nomala
      \ |     n1 - absolute refraction index of material 1
       V|                        sin(angle1)   v1   c/n1   n2        1.0
   -----+------  nr = n2/n1      ----------- = -- = ---- = -- = nr = ---
         \                       sin(angle2)   v2   c/n2   n1        nri
         |    n2 - absolute refraction index of material 2
         \                       n1*sin(angle1) = n2*sin(angle2)
   angle2 | T - transmission vector
in - vector from eye to vertex, must be normalized
n - normal vector
nr - relative refraction index, water nr = 1.33
nri - nri = 1.f/nr
  T = nri*in - nri*(in*n)*n - sqrt( 1.0-nri^2*(1.0-(in,n)^2) )*n   */
// *i - call with nri = 1/relative refraction index
// *n - vector in is Normalized
inline vec RefractedRayin(const vec &in, const vec &n, float nri)	// in from eye to vertex
{
//	float nri=1.f/nr;
	float dot_in_n = DOT3(in,n);
	float a = (float)sqrt( 1.f-nri*nri*(1.f-dot_in_n*dot_in_n) );
	return nri*in - (a+nri*dot_in_n)*n;
}
inline vec RefractedRayi( vec &in, const vec &n, float nri)		// normalize in
{	return RefractedRayin( Normalize(in), n, nri);}
inline vec RefractedRay( vec &in, const vec &n, float nr)
{	return RefractedRayin( Normalize(in), n, 1.f/nr);}

// work also if DOT3( in, n) > 0.f
inline vec RefractedRayic( vec &in, const vec &n, float nri)	// in from eye to vertex
{
	if( DOT3( in, n) > 0.f)
		return RefractedRayi( in, -n, 1.f/nri);
	else 
		return RefractedRayi( in, n, nri);
}

inline float FresnelF0( float nr)
{
	float nri=1.f/nr;
	float f0,f0_;
	f0 = 1-nri;		//      (1-nri)^2
	f0 *= f0;		// f0 = ----------
	f0_ = 1+nri;	//      (1+nri)^2
	f0_ *= f0_;
	f0 /= f0_;
	return f0;
}
// Fresnel
inline float Fresnelin( const vec &in, const vec &n, float nri, float f0)
{
	float dot = DOT3( n, -in);
	float dot2 = dot*dot;
	dot *= dot2*dot2;		// dot = (n*v)^5
	return f0+(1.f-f0)*dot;
}
inline float Fresneli( const vec &in, const vec &n, float nri, float f0)
{	return Fresnelin( Normalize(in), n, nri, f0);}
inline float Fresnel( const vec &in, const vec &n, float nr, float f0)
{	return Fresnelin( Normalize(in), n, 1.f/nr, f0);}

inline float Fresnelin_1( const vec &in, const vec &n, float nri, float f0)
{
	float dot = DOT3( n, -in);	// dot = (n*v)^1
	return f0+(1.f-f0)*dot;
}
inline float Fresnelin_3( const vec &in, const vec &n, float nri, float f0)
{
	float dot = DOT3( n, -in);
	dot *= dot*dot;				// dot = (n*v)^3
	return f0+(1.f-f0)*dot;
}

inline char isInfPlus( const float &x)
{
	float a;
	*(unsigned int*)&a = (unsigned int)0x7f800000;
	return ( x==a);
//	return (*(unsigned int*) &x==0x7f800000);
}

inline float Fresnel2in( const vec &in, const vec &n, float nri)
{
	float k,g;
	
	k = DOT3( in, n);
	g = (float)sqrt(nri*nri+k*k-1);

	float gmk = g-k;
	float gpk = g+k;

	float a = k*gpk-1;
	float b = k*gmk+1;
	return (gmk*gmk/(2*gpk*gpk)) *(1+(a*a)/(b*b));
}
inline float Fresnel2( const vec &in, const vec &n, float nr)
{	return Fresnel2in( Normalize(in), n, 1.f/nr);}



inline char isInfMinus( const float &x)
{
	float a;
	*(unsigned int*)&a = (unsigned int)0xff800000;
	return ( x==a);
//	return (*(unsigned int*) &x==0xff800000);
}


class vec2  
{
public:
	union
	{
		struct
		{
			float x, y;
		};
		float v[2];
	};
	void set( float x_, float y_){ x=x_; y=y_;}
};

class vec4 
{
public:
	union
	{
		struct
		{
			float x, y, z, w;
		};
		float v[4];
	};

	vec4(){}
	inline vec4( const vec4 &a);
	inline vec4( const vec &in);
	inline vec4( const float a, const float b, const float c, const float d = 1.f);
	inline void set( const float a, const float b, const float c, const float d = 1.f);
	inline void clear();
};

inline vec4::vec4( const vec4 &a)
{	x = a.x; y = a.y; z = a.z; w = a.w;}
inline vec4::vec4( const vec &in)
{	x = in.x; y = in.y; z = in.z; w = 1.f;}
inline vec4::vec4( const float a, const float b, const float c, const float d)
{	x = a; y = b; z = c; w = d;}
inline void vec4::set( const float a, const float b, const float c, const float d)
{	x = a; y = b; z = c; w = d;}
inline void vec4::clear()
{	x = 0; y = 0; z = 0; w = 1;}

inline vec::vec( const vec4 &a)
{	x = a.x; y = a.y; z = a.z;}

inline vec::vec( const vec2 &a)
{	x = a.x; y = a.y; z = 0.f;}


inline vec Bspline( const vec &p0, const vec &p1, const vec &p2, const vec &p3, float t)
{
	float t2=t*t;		// t^2
	float c3=t2*t;		// t^3
	float c0,c1,c2;

	c0 = 1.f - t;	c0 *= c0*c0;		// c0 = (1-t)^3
	c1 = 3.f*c3 - 6.f*t2 + 4;			// c1 = 3*t^3 - 6*t^2 + 4
	c2 =-3.f*c3 + 3.f*t2 + 3.f*t + 1.f;	// c2 =-3*t^3 + 3*t^2 + 3*t + 1
//	c3 = t*t*t;
//	vec v = c0*p0 + c1*p1 + c2*p2 + c3*p3;
//	v *= 0.166666666666666666666666666666667f;	// 1/6
	return 0.166666666666666666666666666666667f*(c0*p0 + c1*p1 + c2*p2 + c3*p3);
}

inline vec BsplineDeriv( const vec &p0, const vec &p1, const vec &p2, const vec &p3, float t)
{
	float t2=t*t;		// t^2
	float c0,c1,c2,c3;
//	(1-t)^3 = (1-t)*(1-t-t+t^2) = (1-t)*(1-2*t+t^2) = (1-2*t+t^2 -t +2*t^2 - t^3) = (1-3*t+3*t^2-t^3)
	c0 =-3.f*t2 + 6.f*t - 3;			// c0 =-3*t^2 + 6*t - 3
	c1 = 9.f*t2 -12.f*t;				// c1 = 9*t^2 -12*t
	c2 =-9.f*t2 + 6.f*t + 3;			// c2 =-9*t^2 + 6*t + 3
	c3 = 3.f*t*t;						// c3 = 3*t^2
	return 0.166666666666666666666666666666667f*(c0*p0 + c1*p1 + c2*p2 + c3*p3);
}

inline vec HermiteCurve( const vec &p0, const vec &p1, const vec &t0, const vec &t1, float t)
{
	float t2 = t*t;
	float t3 = t2*t;
	float h1 =  2*t3 - 3*t2 + 1;
	float h2 = -2*t3 + 3*t2;
	float h3 =    t3 - 2*t2 + t;
	float h4 =    t3 -   t2;
	return h1*p0 + h2*p1 + h3*t0 + h4*t1;
}

inline vec HermiteCurveDeriv( const vec &p0, const vec &p1, const vec &t0, const vec &t1, float t)
{
	float t2 = t*t;
	float h1 =  6*t2 - 6*t;
	float h2 = -6*t2 + 6*t;
	float h3 =  3*t2 - 4*t + 1;
	float h4 =  3*t2 - 2*t;
	return h1*p0 + h2*p1 + h3*t0 + h4*t1;
}

#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费大片在线观看| 91国产精品成人| 蜜桃免费网站一区二区三区| 亚洲午夜一二三区视频| 综合久久国产九一剧情麻豆| 亚洲欧美在线另类| 国产精品免费视频观看| 国产精品沙发午睡系列990531| 久久久美女毛片| 国产视频一区在线观看| 国产片一区二区| 中文字幕乱码日本亚洲一区二区| 国产欧美日本一区视频| 中文字幕一区二区三区在线观看| 亚洲欧美区自拍先锋| 一区二区三区毛片| 亚洲国产一二三| 日韩和欧美一区二区三区| 日韩av不卡在线观看| 久久99精品久久久久久动态图| 国产精品99精品久久免费| 99久久精品国产一区二区三区| 色噜噜久久综合| 欧美精品色综合| 欧美精品一区在线观看| 国产精品美日韩| 亚洲最新视频在线观看| 午夜视频一区二区| 久久精品72免费观看| 国产麻豆精品theporn| 成人午夜在线免费| 日本二三区不卡| 欧美一二三四区在线| 久久久久国产成人精品亚洲午夜| 中文字幕日韩一区| 日韩**一区毛片| 国产伦理精品不卡| 色综合网色综合| 91精品国产综合久久精品麻豆| 欧美精品一区二区三区蜜桃 | 欧美激情资源网| 亚洲日本在线天堂| 丝袜美腿亚洲一区二区图片| 国产在线视视频有精品| 91日韩一区二区三区| 91精品国产综合久久久久久| 欧美极品少妇xxxxⅹ高跟鞋 | voyeur盗摄精品| 欧美日韩精品一区二区在线播放| 久久女同互慰一区二区三区| 亚洲在线视频一区| 经典三级视频一区| 在线看国产日韩| 国产三级一区二区| 偷偷要91色婷婷| 99久久精品国产一区| 日韩精品一区二区三区在线观看| 亚洲人成精品久久久久久| 精品无人码麻豆乱码1区2区| 欧美亚洲另类激情小说| 久久精品一区二区三区不卡 | 91激情五月电影| 久久先锋影音av鲁色资源| 亚洲午夜免费电影| 风间由美一区二区三区在线观看| 91麻豆精品国产91久久久久久久久 | 成人激情文学综合网| 日韩一区二区麻豆国产| 一区二区三区美女视频| 国产成a人亚洲| 精品入口麻豆88视频| 亚洲第一久久影院| 99re这里都是精品| 久久影院午夜论| 久久国产精品99久久久久久老狼 | 一本久道久久综合中文字幕 | 亚洲高清久久久| 99精品久久免费看蜜臀剧情介绍| 欧美mv和日韩mv国产网站| 亚洲三级免费观看| 国产成人精品免费看| 日韩欧美精品三级| 偷拍一区二区三区| 91精彩视频在线观看| 国产精品成人一区二区艾草| 高清成人免费视频| 欧美精品一区二区三区久久久| 日韩国产欧美在线视频| 欧美无砖砖区免费| 亚洲精品国产无天堂网2021| 不卡在线视频中文字幕| 中文字幕不卡三区| 国产精品18久久久久久久网站| 精品国产伦一区二区三区免费| 午夜精品视频在线观看| 欧洲av在线精品| 亚洲自拍偷拍网站| 色哦色哦哦色天天综合| 亚洲女人****多毛耸耸8| 91在线播放网址| 亚洲桃色在线一区| 97精品电影院| 亚洲欧洲三级电影| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 国产黄色成人av| 国产视频一区在线播放| 岛国一区二区在线观看| 国产欧美一区在线| 丁香桃色午夜亚洲一区二区三区| 国产欧美一区二区在线| 粉嫩绯色av一区二区在线观看| 国产拍欧美日韩视频二区| 成人理论电影网| 国产精品成人在线观看| 一本大道久久a久久综合 | 欧亚一区二区三区| 亚洲成人激情综合网| 欧美久久久久久久久久| 久久99国产精品久久| 久久久久久久av麻豆果冻| 成人免费视频免费观看| 亚洲视频免费观看| 欧美特级限制片免费在线观看| 天天色天天爱天天射综合| 日韩精品一区二区三区四区| 国产精品伊人色| ...中文天堂在线一区| 在线看国产一区二区| 热久久免费视频| 久久精品一区二区三区四区| 97se亚洲国产综合自在线| 亚洲观看高清完整版在线观看| 7777精品伊人久久久大香线蕉最新版| 日本欧美一区二区| 国产日韩精品一区二区三区在线| 99久久免费视频.com| 亚洲午夜电影在线观看| 日韩你懂的在线播放| 国产69精品久久777的优势| 一区二区三区小说| 日韩一区二区在线观看| 福利视频网站一区二区三区| 亚洲国产成人91porn| 久久久99精品久久| 91蜜桃免费观看视频| 美女一区二区三区| 亚洲人成精品久久久久久 | 亚洲乱码国产乱码精品精小说| 欧美日韩不卡视频| 国产成人综合自拍| 偷拍一区二区三区| 中文字幕欧美国产| 欧美日韩黄色一区二区| 粉嫩高潮美女一区二区三区| 天天亚洲美女在线视频| 国产精品免费丝袜| 欧美一区二区三区性视频| 91网站在线播放| 久久9热精品视频| 亚洲综合网站在线观看| 国产日本一区二区| 91精品国产一区二区三区香蕉| caoporen国产精品视频| 美女诱惑一区二区| 亚洲精品国久久99热| 国产欧美日韩综合| 91精品国产综合久久精品app| 成人动漫在线一区| 另类小说欧美激情| 一级特黄大欧美久久久| 久久精品夜色噜噜亚洲aⅴ| 欧美精品aⅴ在线视频| 99综合电影在线视频| 久久se精品一区精品二区| 亚洲影院久久精品| 亚洲欧洲色图综合| 久久精品亚洲一区二区三区浴池 | 亚洲欧美一区二区三区极速播放| 久久综合丝袜日本网| 欧美精品一二三| 欧美性一级生活| 91蝌蚪porny| 岛国精品在线观看| 国产精品综合二区| 精品系列免费在线观看| 日韩主播视频在线| 性做久久久久久免费观看| 日韩一区欧美小说| 国产精品免费视频一区| 久久九九久久九九| 久久综合九色综合97婷婷| 7777精品伊人久久久大香线蕉的| 色成人在线视频| 色综合久久综合| 91小宝寻花一区二区三区| www.色综合.com| 成人一区二区三区| 国产a级毛片一区| 国产成人免费视频精品含羞草妖精| 九九精品视频在线看|