@@ -125,26 +125,51 @@ public static Shape createRect(double x1, double y1, double x2, double y2) {
125125 }
126126
127127 /**
128- * Creates a {@link Shape} representing a circle.
129- * @param centerPos the center of the circle
130- * @param radius the radius of the circle
131- * @param points the amount of points used to create the circle (at least 3)
128+ * Creates a {@link Shape} representing an ellipse.
129+ * @param centerPos the center of the ellipse
130+ * @param radiusX the x radius of the ellipse
131+ * @param radiusY the y radius of the ellipse
132+ * @param points the amount of points used to create the ellipse (at least 3)
132133 * @return the created {@link Shape}
133134 */
134- public static Shape createCircle (Vector2d centerPos , double radius , int points ) {
135+ public static Shape createEllipse (Vector2d centerPos , double radiusX , double radiusY , int points ) {
135136 if (points < 3 ) throw new IllegalArgumentException ("A shape has to have at least 3 points!" );
136137
137138 Vector2d [] pointArray = new Vector2d [points ];
138139 double segmentAngle = 2 * Math .PI / points ;
139140 double angle = 0d ;
140141 for (int i = 0 ; i < points ; i ++) {
141- pointArray [i ] = centerPos .add (Math .sin (angle ) * radius , Math .cos (angle ) * radius );
142+ pointArray [i ] = centerPos .add (Math .sin (angle ) * radiusX , Math .cos (angle ) * radiusY );
142143 angle += segmentAngle ;
143144 }
144145
145146 return new Shape (pointArray );
146147 }
147148
149+ /**
150+ * Creates a {@link Shape} representing an ellipse.
151+ * @param centerX the x-position of the center of the ellipse
152+ * @param centerY the y-position of the center of the ellipse
153+ * @param radiusX the x radius of the ellipse
154+ * @param radiusY the y radius of the ellipse
155+ * @param points the amount of points used to create the ellipse (at least 3)
156+ * @return the created {@link Shape}
157+ */
158+ public static Shape createEllipse (double centerX , double centerY , double radiusX , double radiusY , int points ) {
159+ return createEllipse (new Vector2d (centerX , centerY ), radiusX , radiusY , points );
160+ }
161+
162+ /**
163+ * Creates a {@link Shape} representing a circle.
164+ * @param centerPos the center of the circle
165+ * @param radius the radius of the circle
166+ * @param points the amount of points used to create the circle (at least 3)
167+ * @return the created {@link Shape}
168+ */
169+ public static Shape createCircle (Vector2d centerPos , double radius , int points ) {
170+ return createEllipse (centerPos , radius , radius , points );
171+ }
172+
148173 /**
149174 * Creates a {@link Shape} representing a circle.
150175 * @param centerX the x-position of the center of the circle
0 commit comments