aboutsummaryrefslogtreecommitdiff
path: root/src/Point3D.java
blob: 843a3942d9f696c7fd262a1d0aaa6bbf3ce9ecc2 (plain) (blame)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*     */ import java.awt.Graphics;
/*     */ 
/*     */ public class Point3D
/*     */ {
/*     */   private double xPos;
/*     */   private double yPos;
/*     */   private double zPos;
/*     */   private double xPivot;
/*     */   private double yPivot;
/*     */   private double zPivot;
/*     */   private PointModel model;
/*     */ 
/*     */   public Point3D(double x, double y, double z, double pivotx, double pivoty, double pivotz, PointModel model)
/*     */   {
/*  21 */     this.xPos = x;
/*  22 */     this.yPos = y;
/*  23 */     this.zPos = z;
/*  24 */     this.xPivot = pivotx;
/*  25 */     this.yPivot = pivoty;
/*  26 */     this.zPivot = pivotz;
/*  27 */     this.model = model;
/*     */   }
/*     */   public Point3D(double x, double y, double z, double pivotx, double pivoty, double pivotz) {
/*  30 */     this(x, y, z, pivotx, pivoty, pivotz, PointModel.TRUE_Euclidean);
/*     */   }
/*     */   public Point3D(double x, double y, double z, PointModel model) {
/*  33 */     this(x, y, z, 0.0D, 0.0D, 0.0D, model);
/*     */   }
/*     */   public Point3D(double x, double y, double z) {
/*  36 */     this(x, y, z, 0.0D, 0.0D, 0.0D, PointModel.TRUE_Euclidean);
/*     */   }
/*     */   public double getX() {
/*  39 */     return this.xPos;
/*     */   }
/*     */   public double getY() {
/*  42 */     return this.yPos;
/*     */   }
/*     */   public double getZ() {
/*  45 */     return this.zPos;
/*     */   }
/*     */   public void setX(double x) {
/*  48 */     this.xPos = x;
/*     */   }
/*     */   public void setY(double y) {
/*  51 */     this.yPos = y;
/*     */   }
/*     */   public void setZ(double z) {
/*  54 */     this.zPos = z;
/*     */   }
/*     */   public void setPointModel(PointModel model) {
/*  57 */     this.model = model;
/*     */   }
/*     */   public double getTrueZ(CoordinateSystem graph) {
/*  60 */     return getRealCoords(graph)[2];
/*     */   }
/*     */ 
/*     */   public double[] getRealCoords(double xPivot, double yPivot, double zPivot, double zRotation, double xRotation, double yRotation, double scale, double xMove, double yMove, double camX, double camY, double camZ) {
/*  64 */     return this.model.getRealCoords(this.xPos, this.yPos, this.zPos, xPivot, yPivot, zPivot, zRotation, xRotation, yRotation, scale, xMove, yMove, camX, camY, camZ);
/*     */   }
/*     */   public double[] getRealCoords(double xPivot, double yPivot, double zPivot, double zRotation, double xRotation, double yRotation) {
/*  67 */     return getRealCoords(xPivot, yPivot, zPivot, zRotation, xRotation, yRotation, 1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D);
/*     */   }
/*     */   public double[] getRealCoords(double zRotation, double xRotation, double yRotation) {
/*  70 */     return getRealCoords(this.xPivot, this.yPivot, this.zPivot, zRotation, xRotation, yRotation, 1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D);
/*     */   }
/*     */   public String toString() {
/*  73 */     return "[" + this.xPos + ", " + this.yPos + ", " + this.zPos + "]";
/*     */   }
/*     */   public double[] getRealCoords(CoordinateSystem graph) {
/*  76 */     double[] realPoints = getRealCoords(graph.getXPivot(), graph.getYPivot(), graph.getZPivot(), graph.getZRotation(), graph.getXRotation(), graph.getYRotation(), graph.getScale(), graph.getXMove(), graph.getYMove(), graph.getCameraX(), graph.getCameraY(), graph.getCameraZ());
/*  77 */     realPoints[0] += graph.getWidth() / 2;
/*  78 */     realPoints[1] += graph.getHeight() / 2;
/*  79 */     return realPoints;
/*     */   }
/*     */   public void drawOn(Graphics g, CoordinateSystem graph) {
/*  82 */     double[] realPoints = getRealCoords(graph.getXPivot(), graph.getYPivot(), graph.getZPivot(), graph.getZRotation(), graph.getXRotation(), graph.getYRotation(), graph.getScale(), graph.getXMove(), graph.getYMove(), graph.getCameraX(), graph.getCameraY(), graph.getCameraZ());
/*     */ 
/*  85 */     g.drawRect((int)(realPoints[0] + graph.getWidth() / 2), (int)(realPoints[1] + graph.getHeight() / 2), (int)(2.0D / graph.getCameraZ() / graph.getScale()), (int)(2.0D / graph.getCameraZ() / graph.getScale()));
/*     */   }
/*     */   public Point3D transpose(double x, double y, double z, double zRotation, double xRotation, double yRotation, double pivotx, double pivoty, double pivotz) {
/*  88 */     double newx = this.xPos;
/*  89 */     double newy = this.yPos;
/*  90 */     double newz = this.zPos;
/*     */ 
/*  92 */     double xd = newx - pivotx;
/*  93 */     double yd = newy - pivoty;
/*  94 */     double zd = newz - pivotz;
/*     */ 
/*  96 */     double zx = xd * Math.cos(Math.toRadians(zRotation)) - yd * Math.sin(Math.toRadians(zRotation)) - xd;
/*  97 */     double zy = xd * Math.sin(Math.toRadians(zRotation)) + yd * Math.cos(Math.toRadians(zRotation)) - yd;
/*     */ 
/*  99 */     double yx = (xd + zx) * Math.cos(Math.toRadians(yRotation)) - zd * Math.sin(Math.toRadians(yRotation)) - (xd + zx);
/* 100 */     double yz = (xd + zx) * Math.sin(Math.toRadians(yRotation)) + zd * Math.cos(Math.toRadians(yRotation)) - zd;
/*     */ 
/* 102 */     double xy = (yd + zy) * Math.cos(Math.toRadians(xRotation)) - (yz + zd) * Math.sin(Math.toRadians(xRotation)) - (yd + zy);
/* 103 */     double xz = (yd + zy) * Math.sin(Math.toRadians(xRotation)) + (yz + zd) * Math.cos(Math.toRadians(xRotation)) - (zd + yz);
/*     */ 
/* 105 */     double xrotooff = yx + zx;
/* 106 */     double yrotooff = zy + xy;
/* 107 */     double zrotooff = xz + yz;
/*     */ 
/* 111 */     return new Point3D(newx + xrotooff + x, newy + yrotooff + y, newz + zrotooff + z, 0.0D, 0.0D, 0.0D);
/*     */   }
/*     */   public void setModel(PointModel model) {
/* 114 */     this.model = model;
/*     */   }
/*     */ 
/*     */   public void invoke(Graphics g)
/*     */   {
/*     */   }
/*     */ }

/* Location:           Modulus.jar
 * Qualified Name:     Point3D
 * JD-Core Version:    0.6.2
 */