From 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 25 Jun 2019 23:58:09 -0400
Subject: [PATCH] Edit panel pin state.

---
 Torus.java |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/Torus.java b/Torus.java
index 8f85353..04aba57 100644
--- a/Torus.java
+++ b/Torus.java
@@ -61,16 +61,25 @@
         if (v == 1)
             v = 0;
         
-        double uAng = LA.toRadians((1-u) * 360);
-        double vAng = LA.toRadians(v * 360);
-        double x = (double)Math.cos(uAng) * (major + (double)Math.cos(vAng) * minor);
-        double y = (double)Math.sin(vAng) * minor;
+        double uAng = u * 2 * Math.PI;
+        double vAng = v * 2 * Math.PI;
+        double cosua = Math.cos(uAng);
+        double sinua = Math.sin(uAng);
+        double cosva = Math.cos(vAng);
+        double sinva = Math.sin(vAng);
+        
+        double radius = (major + cosva * minor);
+        double x = cosua * radius;
+        double y = sinva * minor;
         if (Math.abs(y) < 1E-10)
             y = 0; // hashtable issue
-        double z = (double)Math.sin(uAng) * (major + (double)Math.cos(vAng) * minor);
+        
+        double z = sinua * radius;
         cVector tPos = LA.newVector(x, y, z);
-        double xx = (double)(Math.cos(uAng) * Math.cos(vAng)) * minor;
-        double zz = (double)(Math.sin(uAng) * Math.cos(vAng)) * minor;
+        
+        double xx = cosua * cosva * minor;
+        double zz = sinua * cosva * minor;
+        
         cVector tNorm = LA.newVector(xx, y, zz);
         Vertex temp = new Vertex(tPos);
         //temp.pos = tPos; // useless new
@@ -167,13 +176,13 @@
         return true;
     }
 
-    void doEditDrag(ClickInfo info)
+    void doEditDrag(ClickInfo info, boolean opposite)
     {
         if (hitSomething == 0)
             return;
         if (hitSomething == 1)
         {
-            super.doEditDrag(info);
+            super.doEditDrag(info, opposite);
             return;
         }
         double deltaR = info.x - startX;

--
Gitblit v1.6.2