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

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

?? vector.cpp

?? 一個3D的保齡球的源代碼
?? CPP
字號:
#include "Vector.h"


#include "..\System\fsqrt.h"
#include "..\System\imath.h"

const Vector4s::Type	kNullvector[4] = {0,0,0,0};

/*
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
Vector2s::Type Vector2s::Length() const
{
	return FSqrt(Length2());
}


// ---------------------------------------------------------------------------
//	check if a point is on the right side of a vector (a vector from the 
//	origin to vec and behond)
//	Right side while looking in the direction of the vector
// ---------------------------------------------------------------------------
bool	Vector2s::RightSide(const Vector2s& vec,const Vector2s& point)
{	
	const Type d = Dot(vec.Normal(),point);
	return d <= 0;
}
//

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
const Vector4s& Vector4s::NullVector()
{
	return *((const Vector4s*)kNullvector);
}


#ifdef WIN_DEBUG
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
void _CheckLimit(double val)
{
	SYS_ASSERT(val <= double(INT_MAX) && val >= double(INT_MIN));
};
#endif



// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
void Vector2s::Normalize()
{
	CHK_MULT(x,x);
	CHK_MULT(y,y);

	CHECK_LIMIT( double(x) * double(1<<COS_SIN_SHIFT));
	CHECK_LIMIT( double(y) * double(1<<COS_SIN_SHIFT));

  const int Dist2 = (x*x) + (y*y);   // 2*COS_SIN_SHIFT bits average result for trigo vectors
  const int Dist  = FSqrt(Dist2);

  x = (x << COS_SIN_SHIFT) / Dist;
  y = (y << COS_SIN_SHIFT) / Dist;  
}



// vector used as 3D array index
int Vector4s::LinIndex(int Ix, int Iy, int Iz)
{ 
	int LinearIndex = Ix*(y*z) + Iy*z + Iz;
	return LinearIndex;
}
*/
void Vector4s::Scale(int s)
{ 
	CHK_MULT(s,x);CHK_MULT(s,y);CHK_MULT(s,z);
	
	x = ((s * x) >> COS_SIN_SHIFT); 
	y = ((s * y) >> COS_SIN_SHIFT); 
	z = ((s * z) >> COS_SIN_SHIFT); 
}

// get min values
void Vector4s::getMin(const Vector4s *v2)
{
	if (v2->x < x) x = v2->x;
	if (v2->y < y) y = v2->y;
	if (v2->z < z) z = v2->z;
}

// get max values
void Vector4s::getMax(const Vector4s *v2)
{
	if (v2->x > x) x = v2->x;
	if (v2->y > y) y = v2->y;
	if (v2->z > z) z = v2->z;
}

// cross product with v2, result -> v3
// at least one of the 2 vectors must be normalized, result is normalized
void Vector4s::CrossShift(const Vector4s *V2, Vector4s *Res)const
{
	CHK_MULT(y , V2->z);CHK_MULT(z , V2->y);
	CHK_MULT(z , V2->x);CHK_MULT(x , V2->z);
	CHK_MULT(x , V2->y);CHK_MULT(y , V2->x);
	
	
	Res->x = ((int)y * V2->z - (int)z * V2->y) >> COS_SIN_SHIFT;
	Res->y = ((int)z * V2->x - (int)x * V2->z) >> COS_SIN_SHIFT;
	Res->z = ((int)x * V2->y - (int)y * V2->x) >> COS_SIN_SHIFT;
}

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------

// integer normalize, can be used for rotation vectors
void Vector4s::Normalize()
{
	CHK_MULT(x,x);
	CHK_MULT(y,y);
	CHK_MULT(z,z);
	if (x==0 && y==0 && z== 0)
		return;	
	// normalize x
	int shift = 0;
	if (ABS(x) > (1<<15) || ABS(y) > (1<<15) || ABS(z) > (1<<15))
	{
		x>>=8;
		y>>=8;
		z>>=8;
	}
	SYS_ASSERT(Abs(x) <= SHIFT2VALUE>>1);
	SYS_ASSERT(Abs(y) <= SHIFT2VALUE>>1);
	SYS_ASSERT(Abs(z) <= SHIFT2VALUE>>1);
	int Dist2 = (x*x) + (y*y) + (z*z);   // 2*COS_SIN_SHIFT bits average result for rot vectors
	int Dist  = FSqrt(Dist2, shift);
	x = ((int)x << COS_SIN_SHIFT <<shift) / Dist;
	y = ((int)y << COS_SIN_SHIFT <<shift) / Dist;
	z = ((int)z << COS_SIN_SHIFT <<shift) / Dist;
}

/*
// ---------------------------------------------------------------------------
// static
// ---------------------------------------------------------------------------
const int*	Vector4s::GetReciprocalAxis(int axis)
{
	const static int kPlanes[3][2] = {{1,2},{0,2},{0,1}};
	SYS_ASSERT(axis>=0 && axis < 3);
	return kPlanes[axis];
}



int Vector4s::GetMainAxis() const
{
	const Type x1 = Abs(x);
	const Type y1 = Abs(y);
	const Type z1 = Abs(z);

	if(x1 >= y1)
	{
		if( x1 >= z1)
			return 0;
		else
			return 2;
	}
	else
	{
		if(y1 >= z1)
			return 1;
		else
			return 2;
	}
}

*/

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
void Vector4s::SelfRotateY(int a)
{  
	const Type s = Sinus(a);
	const Type c = Cosinus(a);
	
	const int x1 =	(x*c  + z*s + HALF_PRECISION) >> COS_SIN_SHIFT;
	z =							(x*-s + z*c + HALF_PRECISION) >> COS_SIN_SHIFT;
	x = x1;
}

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
Vector4s Vector4s::GetRotatedY(int a) const
{
	const Type s = Sinus(a);
	const Type c = Cosinus(a);
	
	return Vector4s(	(x*c  + z*s + HALF_PRECISION) >> COS_SIN_SHIFT,
		y,
		(x*-s + z*c + HALF_PRECISION) >> COS_SIN_SHIFT);
}

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
Vector4s Vector4s::GetProjection(const Vector4s& v, const Vector4s& normal)
{
    Vector4s proj = normal;
    proj.Normalize();
    int nDot = Dot(v, proj);
    nDot >>= COS_SIN_SHIFT;
    proj.x = proj.x * nDot >> COS_SIN_SHIFT;
    proj.y = proj.y * nDot >> COS_SIN_SHIFT;
    proj.z = proj.z * nDot >> COS_SIN_SHIFT;
    return proj;
}

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
Vector4s Vector4s::GetReflexion(const Vector4s& v, const Vector4s& normal)
{
    Vector4s proj = GetProjection(v, normal);
    return proj + (proj - v);
}

/*
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
void Vector2s::SelfRotate(int a)
{  
	const Type s = Sinus(a);
	const Type c = Cosinus(a);
	
	const int x1 =	(x*c  + y*s + HALF_PRECISION) >> COS_SIN_SHIFT;
	y =							(x*-s + y*c + HALF_PRECISION) >> COS_SIN_SHIFT;
	x = x1;
}

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
Vector2s Vector2s::GetRotated(int a) const
{
	const Type s = Sinus(a);
	const Type c = Cosinus(a);
	
	return Vector2s(	(x*c  + y*s + HALF_PRECISION) >> COS_SIN_SHIFT,
						(x*-s + y*c + HALF_PRECISION) >> COS_SIN_SHIFT);
}
*/
/*
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
bool RayPlaneInter(const Vector4s& tA,const Vector4s& normal,const Vector4s& rO,const Vector4s& rV,Vector4s& o_point)
{
	int n_dot_v = Vector4s::Dot(normal,rV);
	
	if(n_dot_v!=0)	// Test Paralelism
	{
		Vector4s Q = rO - tA;	// Segment origin, when translated to make d==0
		
		int n_dot_q = Vector4s::Dot(normal,Q);
		
		int t;
		{
			// All this code just for a division !!!
			if(n_dot_q < 0)
			{
				n_dot_q = -n_dot_q;
				n_dot_v = -n_dot_v;
			}
			
			if(n_dot_q &0x7F800000)
			{
				t = -n_dot_q / DownShift16(n_dot_v);
			}
			else if(n_dot_q & 0x007F8000)
				t = -(n_dot_q<<8) / DownShift8(n_dot_v);
			else
				t = -(n_dot_q<<16) / n_dot_v;
			
            CHK_PRECISION(-double(n_dot_q) * (1<<16) / n_dot_v, t, 5);
		}
		
		// insert "t" in the line equation;
		// We do not check if t is restricted to the 
		//	segment since we already checked if both end 
		//	of the segment are on separate side of the plane
		o_point.Init(	DownShift16(rV.x * t) + rO.x,
						DownShift16(rV.y * t) + rO.y,
						DownShift16(rV.z * t) + rO.z);
		return true;
	}
	return false;
}
*/
/*
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
bool RaytriangleIntersect(const Vector4s& tA,const Vector4s& tB,const Vector4s& tC,const Vector4s& normal,	// Triangles vertexes and Normal
						  const Vector4s& rO,const Vector4s& rV,	// Ray Origin and Direction
						  bool doubleSided)
{
	{	// 1- Check if both points (src and dst) are on the same side of the plane:
		// also check if the source is on the front side (backface culling)
		const bool c1 = FrontSide(tA,normal,rO);
		
		if(c1 ==false && !doubleSided)
			return false;
		
		const bool c2 = FrontSide(tA,normal,rO + rV);
		
		if(c1==c2)
			return false;
	}
	
	Vector4s point;
	if(RayPlaneInter(tA,normal,rO,rV,point))
	{
		const int* raxis = Vector4s::GetReciprocalAxis(normal.GetMainAxis());
		
		const Vector2s	p0 = point.GetVector2s(raxis);
		
		const Vector2s	pa = tA.GetVector2s(raxis);
		const Vector2s	pb = tB.GetVector2s(raxis);
		const Vector2s	pc = tC.GetVector2s(raxis);
		
		// If the point is on the same side of each of these vectors, 
		// it means it is inside the polygon.
		
        int d1 = Vector2s::Dot((pb-pa).Normal(),(p0-pa));
        int d2 = Vector2s::Dot((pc-pb).Normal(), (p0-pb));
        if ((d1 <= 0 && d2 <= 0) || (d1 >= 0 && d2 >= 0))
        {
            int d3 = Vector2s::Dot((pa-pc).Normal(), (p0-pc));
            if ((d1 <= 0 && d2 <= 0 && d3 <= 0) || (d1 >= 0 && d2 >= 0 && d3 >= 0))
            {
                return true;
            }
        }
	}
	return false;
}
*/
/*
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
int FindRaytriangleIntersectionPoint(	const Vector4s& tA,const Vector4s& tB,const Vector4s& tC,const Vector4s& normal,	// Triangles vertexes and Normal
									 const Vector4s& rO,Vector4s& dst,	// Ray Origin and destination
									 bool doubleSided)
{
	{	// 1- Check if both points (src and dst) are on the same side of the plane:
		// also check if the source is on the front side (backface culling)
		const bool c1 = FrontSide(tA,normal,rO);
		
		if(c1 ==false && !doubleSided)
			return INT_MAX;
		
		const bool c2 = FrontSide(tA,normal,dst);
		
		if(c1==c2)
			return INT_MAX;
	}
	
	Vector4s point;
	if(RayPlaneInter(tA,normal,rO,dst - rO,point))
	{
		const int minDist	= (dst - rO).Length2();
		const int dist2		= (point - rO).Length2();
		
		if(dist2 < minDist)
		{
			const int* raxis = Vector4s::GetReciprocalAxis(normal.GetMainAxis());
			
			const Vector2s	p0 = point.GetVector2s(raxis);
			
			const Vector2s	pa = tA.GetVector2s(raxis);
			const Vector2s	pb = tB.GetVector2s(raxis);
			const Vector2s	pc = tC.GetVector2s(raxis);
			
			// If the point is on the same side of each of these vectors, 
			// it means it is inside the polygon.
			
			int d1 = Vector2s::Dot((pb-pa).Normal(),(p0-pa));
			int d2 = Vector2s::Dot((pc-pb).Normal(), (p0-pb));
			
			if ((d1 <= 0 && d2 <= 0) || (d1 >= 0 && d2 >= 0))
			{
				int d3 = Vector2s::Dot((pa-pc).Normal(), (p0-pc));
				if ((d1 <= 0 && d2 <= 0 && d3 <= 0) || (d1 >= 0 && d2 >= 0 && d3 >= 0))
				{
					dst = point;
					return dist2;
				}
			}
		}
	}
	return INT_MAX;
}
*/

// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
/*
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
bool Vector2s::Intersect(const Vector2s& A,const Vector2s& B,const Vector2s& C,const Vector2s& D)
{
	SYS_ASSERT(A.x <= B.x && C.x <= D.x);
	
	const int BAx = B.x-A.x;
	const int BAy = B.y-A.y;
	
	const int DCx = D.x-C.x;
	const int DCz = D.y-C.y;
	
	const int d = BAx*DCz - BAy*DCx;
	
	if(d==0)	// Parellel
		return false;
	
	const int ACz = A.y - C.y;
	const int ACx = A.x - C.x;
	
	const int r = ACz*DCx - ACx*DCz;
	const int s = ACz*BAx - ACx*BAy;
	
	if(d<0)
	{
		if( r<=0 && r>=d && s<=0 && s>=d)
			return true;			
	}
	else
	{
		if( r>=0 && r<=d && s>=0 && s<=d)
			return true;		
	}
	return false;
}


*/










?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
黄页视频在线91| 国产一区福利在线| 国产亚洲欧美色| 色激情天天射综合网| 久久成人18免费观看| 亚洲国产中文字幕| 国产精品久久久久四虎| 日韩美女在线视频| 欧美日韩国产成人在线91| 91视频在线观看| 国产一区激情在线| 奇米精品一区二区三区四区| 亚洲精品亚洲人成人网在线播放| 精品国产成人在线影院| 欧美久久一二三四区| 色婷婷综合五月| 国产99久久久国产精品潘金 | 91免费国产在线| 国产美女精品在线| 蜜臀av一区二区在线免费观看| 亚洲女同一区二区| 亚洲婷婷综合久久一本伊一区| 久久精品水蜜桃av综合天堂| 精品国产乱码久久久久久闺蜜| 91精品久久久久久蜜臀| 欧美日韩一区二区三区在线| 成人国产精品免费观看动漫| 国产精品99久久不卡二区| 国产一区二区三区免费在线观看| 日本在线播放一区二区三区| 日韩经典一区二区| 午夜精品在线看| 亚洲v精品v日韩v欧美v专区| 亚洲一本大道在线| 亚洲第一福利视频在线| 亚洲与欧洲av电影| 亚洲香肠在线观看| 天天综合网 天天综合色| 亚洲一区二区综合| 亚洲午夜电影在线观看| 图片区小说区区亚洲影院| 亚洲成av人片一区二区梦乃| 亚洲成人av在线电影| 午夜精品一区二区三区三上悠亚| 亚洲大片在线观看| 天天爽夜夜爽夜夜爽精品视频| 亚洲成av人片| 蜜臀av一区二区| 国产在线精品一区在线观看麻豆| 久88久久88久久久| 国产精品亚洲专一区二区三区 | 不卡的av在线播放| 99精品欧美一区| 91精品福利视频| 欧美日韩dvd在线观看| 欧美成人精品高清在线播放| 精品国产乱码久久久久久久久| 国产区在线观看成人精品 | 日本不卡一二三| 国产在线视频精品一区| av高清久久久| 欧美精品精品一区| 精品精品欲导航| 国产精品视频九色porn| 一区二区三区精品视频在线| 日韩不卡一二三区| 福利一区二区在线| 91久久精品网| 精品久久人人做人人爱| 国产精品久久久久久福利一牛影视 | 国产精品久久久久久久久免费樱桃 | 亚洲最大色网站| 麻豆91在线播放| 国产99久久久国产精品潘金| 日本道精品一区二区三区| 日韩亚洲国产中文字幕欧美| 国产精品欧美经典| 天天操天天色综合| 风间由美中文字幕在线看视频国产欧美| 91在线小视频| 日韩视频免费直播| 亚洲欧洲日韩在线| 麻豆精品久久久| 93久久精品日日躁夜夜躁欧美| 欧美精品成人一区二区三区四区| 久久精品视频在线免费观看| 亚洲一区二区三区中文字幕| 激情综合色综合久久综合| 色噜噜夜夜夜综合网| 日韩免费在线观看| 亚洲免费在线视频| 国产成人免费视频网站| 欧美日韩精品一区二区在线播放| 国产女主播一区| 粉嫩嫩av羞羞动漫久久久| 欧美喷潮久久久xxxxx| 久久嫩草精品久久久久| 亚洲电影第三页| www.日韩大片| 久久婷婷成人综合色| 亚洲成av人影院| 91麻豆免费在线观看| 国产亚洲精品资源在线26u| 亚洲成人第一页| 色综合视频一区二区三区高清| 久久久亚洲午夜电影| 欧美96一区二区免费视频| 色婷婷精品久久二区二区蜜臀av| 国产调教视频一区| 美女脱光内衣内裤视频久久影院| 91国模大尺度私拍在线视频| 国产精品婷婷午夜在线观看| 免费在线一区观看| 欧美日本韩国一区二区三区视频| **性色生活片久久毛片| 国产69精品一区二区亚洲孕妇| 日韩欧美一区二区三区在线| 日韩精品免费专区| 欧美熟乱第一页| 一区二区久久久| 91久久人澡人人添人人爽欧美| 中文字幕一区日韩精品欧美| 国产99久久久国产精品潘金 | 91麻豆精品国产91久久久使用方法 | 97久久精品人人做人人爽50路| 2020国产精品自拍| 久久精品国产亚洲一区二区三区 | 中文字幕在线播放不卡一区| 成人午夜激情在线| 国产欧美一区二区三区沐欲 | 国产精品综合av一区二区国产馆| 日韩欧美激情四射| 美女一区二区三区| 日韩三级视频中文字幕| 日韩电影免费在线看| 91精品国产综合久久久蜜臀粉嫩 | 亚洲成人一区在线| 欧美日韩在线三级| 午夜av电影一区| 91精品国产色综合久久不卡蜜臀 | 亚洲综合成人网| 欧美亚洲国产一区在线观看网站 | 高清成人免费视频| 中文字幕一区二区三区av| 99精品黄色片免费大全| 一个色综合网站| 欧美日韩久久久久久| 麻豆中文一区二区| 久久久777精品电影网影网| 成人福利在线看| 亚洲视频一二三| 欧美日韩国产精品自在自线| 蜜桃av一区二区| 久久久综合精品| 91在线无精精品入口| 图片区小说区区亚洲影院| 欧美mv和日韩mv国产网站| 成人美女视频在线看| 一区二区国产盗摄色噜噜| 欧美日韩电影在线| 极品美女销魂一区二区三区免费| 亚洲国产成人午夜在线一区| 色香色香欲天天天影视综合网| 日韩电影一区二区三区四区| 国产视频一区在线观看| 色综合咪咪久久| 美女精品自拍一二三四| 亚洲国产精品激情在线观看| 色视频欧美一区二区三区| 日韩av一区二区三区四区| 久久久久97国产精华液好用吗| 99精品国产热久久91蜜凸| 日本欧美肥老太交大片| 国产精品久久久久9999吃药| 欧美午夜电影网| 国产乱理伦片在线观看夜一区| 亚洲综合色婷婷| 久久精品欧美日韩精品| 欧美最新大片在线看| 久久9热精品视频| 亚洲美女一区二区三区| 日韩一级视频免费观看在线| 不卡免费追剧大全电视剧网站| 奇米影视一区二区三区小说| 中文字幕一区三区| 欧美tk—视频vk| 欧美专区亚洲专区| 国产激情一区二区三区四区| 午夜精品福利一区二区三区av| 久久日一线二线三线suv| 91国内精品野花午夜精品| 国产成人精品网址| 免费视频一区二区| 亚洲午夜精品在线| 中文字幕一区二区三区乱码在线| 精品av综合导航| 欧美日韩国产高清一区二区三区 | 亚洲欧美日韩久久精品| 亚洲精品一区二区在线观看| 欧美系列一区二区|