⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 math.cs

📁 Game Engine Desing Direct X and C#.rar
💻 CS
字号:
using System;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace GameEngine
{
	/// <summary>
	/// Summary description for GameMath.
	/// </summary>
	public class GameMath
	{
		public GameMath()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public static Vector3 ComputeFaceNormal( Vector3 p1, Vector3 p2, Vector3 p3 )
		{
			Vector3 Normal;

			Vector3 V1 = Vector3.Subtract(p1,p2);
			Vector3 V2 = Vector3.Subtract(p3,p1);
			Normal = Vector3.Cross( V1, V2 );
			Normal.Normalize();

			return Normal;
		}

		public static bool InRect( Rectangle rect, Vector3 pt)
		{
			bool inside =  pt.X >= rect.Left && pt.X <= rect.Right && 
				           pt.Z >= rect.Bottom && pt.Z <= rect.Top;

			return inside;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -