@@ -7,6 +7,8 @@ public class Parabola {
77 double Radius , w , a , b , FocalLength ;
88 boolean fromEq = true ;
99
10+ private static double numberOfPoints = 64 ;
11+
1012 // from https://www.mathsisfun.com/geometry/parabola.html
1113 private Parabola () {
1214
@@ -46,7 +48,7 @@ public Parabola fromFocalLength(double Radius, double Focus) {
4648 public ArrayList <Vector3d > getpoints () {
4749 ArrayList <Vector3d > points = new ArrayList <>();
4850 points .add (new Vector3d (0 , computeY (Radius )));
49- for (double i = 0 ; i <= 1 ; i += 0.05 ) {
51+ for (double i = 0 ; i <= 1 ; i += ( 1.0 / numberOfPoints ) ) {
5052 double x = Radius * i ;
5153 double y = computeY (x );
5254 points .add (new Vector3d (x , y ));
@@ -59,9 +61,8 @@ public static CSG coneByEquation(double Radius, double a, double b) {
5961 ArrayList <Vector3d > points = new Parabola ().fromEquation (Radius , a , b ).getpoints ();// upper
6062 // right
6163 // corner
62-
6364 ArrayList <Vector3d > pointsOut = new ArrayList <>();
64- for (double i = 0 ; i <= 360 ; i += 10 ) {
65+ for (double i = 0 ; i <= 360 ; i += ( 360.0 / numberOfPoints ) ) {
6566 Transform transform = new Transform ().roty (i );
6667 for (Vector3d p : points )
6768 pointsOut .add (p .transformed (transform ));
@@ -71,22 +72,21 @@ public static CSG coneByEquation(double Radius, double a, double b) {
7172 }
7273
7374 public static CSG cone (double Radius , double height ) {
74- return coneByHeight (Radius , height , 0 ).rotx (90 ).toZMin ();
75+ return coneByHeight (Radius , height ).rotx (90 ).toZMin ();
7576 }
76- public static CSG cone (double Radius , double height , double b ) {
77- return coneByHeight (Radius , height , b ).rotx (90 ).toZMin ();
78- }
79- public static CSG coneByHeight (double Radius , double height ) {
80- return coneByHeight (Radius , height , 0 );
77+ public static CSG cone (double Radius , double height , double np ) {
78+ numberOfPoints = np ;
79+ return coneByHeight (Radius , height ).rotx (90 ).toZMin ();
8180 }
8281
83- public static CSG coneByHeight (double Radius , double height , double b ) {
82+ public static CSG coneByHeight (double Radius , double height ) {
83+ double b = 0 ;
8484 double a = (height - (b * Radius )) / (Radius * Radius );
8585 ArrayList <Vector3d > points = new Parabola ().fromEquation (Radius , a , b ).getpoints ();// upper
8686 // right
8787 // corner
8888 ArrayList <Vector3d > pointsOut = new ArrayList <>();
89- for (double i = 0 ; i <= 360 ; i += 10 ) {
89+ for (double i = 0 ; i <= 360 ; i += ( 360 / numberOfPoints ) ) {
9090 Transform transform = new Transform ().roty (i );
9191 for (Vector3d p : points )
9292 pointsOut .add (p .transformed (transform ));
0 commit comments