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

📄 vector3.java

📁 ErGo是一个很早的Java通用围棋服务器(IGS/NNGS)客户端程序。有全部源码和文档
💻 JAVA
字号:
package ergo.ui;

// $Id: Vector3.java,v 1.2 1999/08/13 01:20:11 sigue Exp $

/*
 *  Copyright (C) 1999  Carl L. Gay and Antranig M. Basman.
 *  See the file copyright.txt, distributed with this software,
 *  for further information.
 */

// A vector in R3

public class Vector3 {
  double x, y, z;
  Vector3() {};
  Vector3(double x, double y, double z) {
    this.x = x; this.y = y; this.z = z;
  }
  Vector3 norm() {
    double d = Math.sqrt(x*x + y*y + z*z);
    x/=d; y/=d; z/=d;
    return this;
  }
  void imbue(double x, double y, double z) {
    this.x=x; this.y=y; this.z=z;
  }
  double dot(Vector3 other) {
    return x*other.x + y*other.y + z*other.z;
  }
  static void subhorr(Vector3 target, Vector3 a, Vector3 b) {
    target.x = a.x - b.x; target.y = a.y - b.y; target.z = a.z - b.z;
  }
  static void addhorr(Vector3 target, Vector3 a, Vector3 b) {
    target.x = a.x + b.x; target.y = a.y + b.y; target.z = a.z + b.z;
  }
  static void scalehorr(Vector3 target, double f, Vector3 a) {
    target.x = f*a.x; target.y = f*a.y; target.z = f*a.z;
  }
}

⌨️ 快捷键说明

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