@@ -123,27 +123,52 @@ public static Shape createRect(Vector2d pos1, Vector2d pos2) {
123123 public static Shape createRect (double x1 , double y1 , double x2 , double y2 ) {
124124 return createRect (new Vector2d (x1 , y1 ), new Vector2d (x2 , y2 ));
125125 }
126-
126+
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!" );
136-
137+
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 }
144-
145+
145146 return new Shape (pointArray );
146147 }
148+
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+ }
147172
148173 /**
149174 * Creates a {@link Shape} representing a circle.
0 commit comments