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 package net.sourceforge.kamiwaai.geometricalgebra;
46
47 import java.awt.Color;
48 import java.awt.Graphics;
49 import java.awt.Graphics2D;
50 import java.awt.geom.Ellipse2D;
51
52 public class PointC extends GeometricObject {
53
54
55 private Color color = Color.blue;
56
57 private Color rightcolor = Color.green;
58
59 private int pointsize = 10;
60
61 public PointC() {
62 L = nbar;
63 }
64
65 public PointC(double e1c, double e2c, double e3c) {
66 L = nbar;
67
68
69
70
71
72
73
74
75 MultiVector Tc = One.add(n.mult(e1.multSc(e1c - L.ScProd(e1))).multSc(0.5)).add(
76 n.mult(e2.multSc(e2c - L.ScProd(e2))).multSc(0.5)).add(
77 n.mult(e3.multSc(e3c - L.ScProd(e3))).multSc(0.5));
78 L = Tc.mult(L).mult(Tc.reverse());
79 }
80
81 public PointC(MultiVector L1) {
82 L = L1;
83 }
84
85 public void sete1(double e1c) {
86 MultiVector Tc, Tcr;
87 Tc = One.add(n.mult(e1.multSc(e1c - L.ScProd(e1))).multSc(0.5));
88 Tcr = Tc.reverse();
89 L = Tc.mult(L).mult(Tcr);
90 }
91
92 public void sete2(double e2c) {
93 MultiVector Tc, Tcr;
94 Tc = One.add(n.mult(e2.multSc(e2c - L.ScProd(e2))).multSc(0.5));
95 Tcr = Tc.reverse();
96 L = Tc.mult(L).mult(Tcr);
97 }
98
99 public void sete3(double e3c) {
100 MultiVector Tc, Tcr;
101 Tc = One.add(n.mult(e3.multSc(e3c - L.ScProd(e3))).multSc(0.5));
102 Tcr = Tc.reverse();
103 L = Tc.mult(L).mult(Tcr);
104 }
105
106 public void setColor(Color c) {
107 color = c;
108 }
109
110 public void setRightColor(Color rc) {
111 rightcolor = rc;
112 }
113
114 public void setSize(int s) {
115 pointsize = s;
116 }
117
118 double[] coord() {
119 double[] lps = new double[3];
120 lps[0] = L.ScProd(e1);
121 lps[1] = L.ScProd(e2);
122 lps[2] = L.ScProd(e3);
123 return lps;
124 }
125
126 public void draw(Graphics gg) {
127 Graphics2D g = (Graphics2D) gg;
128
129 Ellipse2D.Double disk = new Ellipse2D.Double(L.ScProd(e1) - pointsize
130 / 2, L.ScProd(e2) - pointsize / 2, pointsize, pointsize);
131 g.setColor(color);
132 g.fill(disk);
133
134 g.setColor(Color.black);
135 g.draw(disk);
136 }
137
138 public void erase(Graphics gg) {
139 Graphics2D g = (Graphics2D) gg;
140
141 Ellipse2D.Double disk = new Ellipse2D.Double(L.ScProd(e1) - pointsize
142 / 2, L.ScProd(e2) - pointsize / 2, pointsize, pointsize);
143 g.setColor(g.getBackground());
144 g.fill(disk);
145
146 g.draw(disk);
147 }
148
149 public void eraseZ(Graphics gg) {
150 Graphics2D g = (Graphics2D) gg;
151
152 Ellipse2D.Double disk = new Ellipse2D.Double(L.ScProd(e3) - pointsize
153 / 2, L.ScProd(e2) - pointsize / 2, pointsize, pointsize);
154 g.setColor(g.getBackground());
155 g.fill(disk);
156
157 g.draw(disk);
158 }
159
160 public void drawZ(Graphics gg) {
161 Graphics2D g = (Graphics2D) gg;
162
163 Ellipse2D.Double disk = new Ellipse2D.Double(L.ScProd(e3) - pointsize
164 / 2, L.ScProd(e2) - pointsize / 2, pointsize, pointsize);
165 g.setColor(rightcolor);
166 g.fill(disk);
167
168 g.setColor(Color.black);
169 g.draw(disk);
170 }
171
172 double ppdistance(PointC pc2) {
173 return Math.sqrt(-2.0 * L.ScProd(pc2.getMultiVector()));
174 }
175
176 public boolean isXYpoint(double x, double y) {
177 boolean checkpoint = false;
178 double ddxy2 = (L.ScProd(e1) - x) * (L.ScProd(e1) - x)
179 + (L.ScProd(e2) - y) * (L.ScProd(e2) - y);
180 if (ddxy2 <= pointsize / 2 * pointsize / 2)
181 checkpoint = true;
182 return checkpoint;
183 }
184
185 public boolean isYZpoint(double y, double z) {
186 boolean checkpoint = false;
187 double ddyz2 = (L.ScProd(e2) - y) * (L.ScProd(e2) - y)
188 + (L.ScProd(e3) - z) * (L.ScProd(e3) - z);
189 if (ddyz2 <= pointsize / 2 * pointsize / 2)
190 checkpoint = true;
191 return checkpoint;
192 }
193
194 }