(Vec3 A, Vec3 B, Vec3 C)
| 242 | } |
| 243 | |
| 244 | static public Vec3 circumcenterOf(Vec3 A, Vec3 B, Vec3 C) { |
| 245 | Vec3 r = new Vec3(); |
| 246 | if (A.z == 0.0 && B.z == 0.0 && C.z == 0.0) { |
| 247 | double u = ((A.x - B.x) * (A.x + B.x) + (A.y - B.y) * (A.y + B.y)) / 2.0; |
| 248 | double v = ((B.x - C.x) * (B.x + C.x) + (B.y - C.y) * (B.y + C.y)) / 2.0; |
| 249 | double den = (A.x - B.x) * (B.y - C.y) - (B.x - C.x) * (A.y - B.y); |
| 250 | r.set(0, (float) ((u * (B.y - C.y) - v * (A.y - B.y)) / den)); |
| 251 | r.set(1, (float) ((v * (A.x - B.x) - u * (B.x - C.x)) / den)); |
| 252 | r.set(2, (float) 0.0); |
| 253 | } else { |
| 254 | Vec3 BmA = Vec3.sub(B, A, new Vec3()); |
| 255 | Vec3 CmA = Vec3.sub(C, A, new Vec3()); |
| 256 | |
| 257 | double BC = BmA.dot(CmA); |
| 258 | double B2 = BmA.lengthSquared(), C2 = CmA.lengthSquared(); |
| 259 | double den = 2.0 * (B2 * C2 - BC * BC); |
| 260 | double s = C2 * (B2 - BC) / den; |
| 261 | double t = B2 * (C2 - BC) / den; |
| 262 | |
| 263 | Vec3.fma(BmA, (float) s, A, r); |
| 264 | Vec3.fma(CmA, (float) t, r, r); |
| 265 | } |
| 266 | return r; |
| 267 | } |
| 268 | |
| 269 | static public Vec2 circumcenterOf(Vec2 A, Vec2 B, Vec2 C) { |
| 270 | Vec2 r = new Vec2(); |
nothing calls this directly
no test coverage detected