JavaCAD
Matrix3d.java
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 package eu.mihosoft.vrl.v3d;
7 
8 // TODO: Auto-generated Javadoc
14 public class Matrix3d {
15 
17  public double m11, m12, m13;
18 
20  public double m21, m22, m23;
21 
23  public double m31, m32, m33;
24 
26  public static final Matrix3d ZERO = new Matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0);
27 
29  public static final Matrix3d UNITY = new Matrix3d(1, 0, 0, 0, 1, 0, 0, 0, 1);
30 
44  public Matrix3d(double m11, double m12, double m13,
45  double m21, double m22, double m23,
46  double m31, double m32, double m33) {
47  this.m11 = m11;
48  this.m12 = m12;
49  this.m13 = m13;
50  this.m21 = m21;
51  this.m22 = m22;
52  this.m23 = m23;
53  this.m31 = m31;
54  this.m32 = m32;
55  this.m33 = m33;
56  }
57 
58  /* (non-Javadoc)
59  * @see java.lang.Object#toString()
60  */
61  @Override
62  public String toString() {
63  return "[" + m11 + ", " + m12 + ", " + m13 + "]\n"
64  + "[" + m21 + ", " + m22 + ", " + m23 + "]\n"
65  + "[" + m31 + ", " + m32 + ", " + m33 + "]";
66  }
67 
68  /* (non-Javadoc)
69  * @see java.lang.Object#equals(java.lang.Object)
70  */
71  @Override
72  public boolean equals(Object obj) {
73  if (obj == null) {
74  return false;
75  }
76  if (getClass() != obj.getClass()) {
77  return false;
78  }
79  final Matrix3d other = (Matrix3d) obj;
80  if (Double.doubleToLongBits(this.m11) != Double.doubleToLongBits(other.m11)) {
81  return false;
82  }
83  if (Double.doubleToLongBits(this.m12) != Double.doubleToLongBits(other.m12)) {
84  return false;
85  }
86  if (Double.doubleToLongBits(this.m13) != Double.doubleToLongBits(other.m13)) {
87  return false;
88  }
89  if (Double.doubleToLongBits(this.m21) != Double.doubleToLongBits(other.m21)) {
90  return false;
91  }
92  if (Double.doubleToLongBits(this.m22) != Double.doubleToLongBits(other.m22)) {
93  return false;
94  }
95  if (Double.doubleToLongBits(this.m23) != Double.doubleToLongBits(other.m23)) {
96  return false;
97  }
98  if (Double.doubleToLongBits(this.m31) != Double.doubleToLongBits(other.m31)) {
99  return false;
100  }
101  if (Double.doubleToLongBits(this.m32) != Double.doubleToLongBits(other.m32)) {
102  return false;
103  }
104  if (Double.doubleToLongBits(this.m33) != Double.doubleToLongBits(other.m33)) {
105  return false;
106  }
107  return true;
108  }
109 
119  public Matrix3d times(double a) {
120  return new Matrix3d(
121  m11 * a, m12 * a, m13 * a,
122  m21 * a, m22 * a, m23 * a,
123  m31 * a, m32 * a, m33 * a);
124  }
125 
135  public Vector3d times(Vector3d a) {
136  return new Vector3d(
137  m11 * a.x + m12 * a.y + m13 * a.z,
138  m21 * a.x + m22 * a.y + m23 * a.z,
139  m31 * a.x + m32 * a.y + m33 * a.z);
140  }
141 
142 }
boolean equals(Object obj)
Definition: Matrix3d.java:72
static final Matrix3d UNITY
Definition: Matrix3d.java:29
Vector3d times(Vector3d a)
Definition: Matrix3d.java:135
static final Matrix3d ZERO
Definition: Matrix3d.java:26
Matrix3d times(double a)
Definition: Matrix3d.java:119
Matrix3d(double m11, double m12, double m13, double m21, double m22, double m23, double m31, double m32, double m33)
Definition: Matrix3d.java:44
static Vector3d y(double y)
Definition: Vector3d.java:484
static Vector3d z(double z)
Definition: Vector3d.java:494
static Vector3d x(double x)
Definition: Vector3d.java:474