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

📄 vector2d.java

📁 一个J2ME的3D 一个J2ME的3D 一个J2ME的3D
💻 JAVA
字号:
/**
 * 
 */
package Math;

/**
 * @author PanXu
 *
 */
public class Vector2D {
	/**
	 * 
	 */
	public static final int X = 0 ;
	public static final int Y = 0 ;
	
	public float M[] = null;
	public Vector2D() {
		super();
		// TODO 自动生成构造函数存根
		M = new float [2];
		M[0] = 0 ;
		M[1] = 0 ;
	}
	public Vector2D(float x , float y) {
		super();
		// TODO 自动生成构造函数存根
		M = new float [2];
		M[0] = x ;
		M[1] = y ;
	}
	/*
	 * Build
	 */
	public void Init (float x ,float y , float z)
	{
		this .M[0] = x;
		this .M[1] = y;
	}
	public static Vector2D Build_Vec2D_Stack (Point2D s , Point2D e)
	{
		return new Vector2D (e.M[0] - s.M[0] , e.M[1] - s.M[1]);
	}
	
	public void Build_Vec2D (Point2D s , Point2D e)
	{
		this .M[0] = e.M[0] - s.M[0];
		this .M[1] = e .M[1] - s.M[1];
	}
	public void Set_Zero ()
	{
		this .M[0] = 0 ; this .M[1] = 0;
	}
	/*
	 * 运算
	 */
	//加
	public Vector2D Vec2D_ADD_Stack (Vector2D a , Vector2D b){
		Vector2D res = new Vector2D();
		res .M[0] = a .M[0] + b.M[0];
		res .M[1] = a .M[1] + b.M[1];
		return res ;
	}
	public void Vec2D_ADD (Vector2D a , Vector2D b){
		this .M[0] = a .M[0] + b.M[0];
		this .M[1] = a .M[1] + b.M[1];
	}
	//减
	public Vector2D Vec2D_SUB_Stack (Vector2D a , Vector2D b){
		Vector2D res = new Vector2D();
		res .M[0] = a .M[0] - b.M[0];
		res .M[1] = a .M[1] - b.M[1];
		return res ;
	}
	public void Vec2D_SUB (Vector2D a , Vector2D b){
		this .M[0] = a .M[0] - b.M[0];
		this .M[1] = a .M[1] - b.M[1];
	}
	//点积
	public float Vec2D_DOT (Vector2D a , Vector2D b)
	{
		return (a.M[0] * b.M[0] + a.M[1] * b.M[1]);
	}
}

⌨️ 快捷键说明

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