-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTVector3d.java
More file actions
86 lines (72 loc) · 1.04 KB
/
Copy pathTVector3d.java
File metadata and controls
86 lines (72 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// vector class
//
// provides 3d vectors to Vertex
//
public class TVector3d
{
// components of the vector
private float _X;
private float _Y;
private float _Z;
// constuctors
public TVector3d (double X, double Y, double Z)
{
_X = (float)X;
_Y = (float)Y;
_Z = (float)Z;
}
public TVector3d (float X, float Y, float Z)
{
_X = X;
_Y = Y;
_Z = Z;
}
// selectors
public float X()
{
return _X;
}
public float Y()
{
return _Y;
}
public float Z()
{
return _Z;
}
// operations
// length
public float Length()
{
return (float)(Math.sqrt( (_X * _X) + (_Y * _Y) + (_Z * _Z) ));
}
// unit
public void Unit()
{
float Length = this.Length();
_X = _X / Length;
_Y = _Y / Length;
_Z = _Z / Length;
}
// fix length
public void FixLength(float Length)
{
this.Unit();
_X = _X * Length;
_Y = _Y * Length;
_Z = _Z * Length;
}
// Is Equal
public boolean IsEqual(TVector3d B)
{
if ( (_X == B.X()) && (_Y == B.Y()) && (_Z == B.Z()) )
{
return true;
}
else
{
return false;
}
}
}