国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

構建向量類Vecto4

2019-11-09 19:32:57
字體:
來源:轉載
供稿:網友

定義一個Vector4向量

class Vector4{ public double x,y,z,w; //構造函數1 public Vector4(){} //構造函數2 public Vector4(double x, double y, double z, double w) { this.x = x; this.y = y; this.z = z; this.w = w; } //構造函數3 public Vector4(Vector4 v) { this.x = v.x; this.y = v.y; this.z = v.z; this.w = v.w; } //兩個向量減法 public static Vector4 Operator-(Vector4 a, Vector4 b) { Vector4 c = new Vector4(); c.x = a.x - b.x; c.y = a.y - b.y; c.z = a.z - b.z; c.w = a.w - b.w; return c; } //兩個向量加法 public static Vector4 operator+(Vector4 a, Vector4 b) { Vector4 c = new Vector4(); c.x = a.x + b.x; c.y = a.y + b.y; c.z = a.z + b.z; c.w = a.w + b.w; return c; } //兩個向量點乘 public double Dot(Vector4 v) { return this.x*v.x + this.y*v.y + this.z*v.z; } //兩個向量叉乘 public Vector4 Cross(Vector4 v) { return new Vector4(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * y - this.y * v.x, 0); }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 英吉沙县| 长葛市| 吉木萨尔县| 阿图什市| 镇宁| 五华县| 苍南县| 新乡县| 大城县| 铅山县| 潜江市| 宜州市| 西和县| 西青区| 彩票| 绍兴县| 郧西县| 万安县| 晋江市| 黎城县| 固原市| 平阴县| 普格县| 丰镇市| 宁明县| 江华| 扬州市| 叶城县| 蕉岭县| 醴陵市| 濉溪县| 玉环县| 荥经县| 万源市| 翁源县| 涿鹿县| 普陀区| 信阳市| 白朗县| 清水县| 台南市|