2 * Sixth - System for data storage, computation, exploration and interaction.
3 * Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
12 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
13 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
14 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape;
16 import java.util.ArrayList;
18 public class WireframeSphere extends AbstractCompositeShape {
20 ArrayList<Point3D> previousRing = new ArrayList<>();
22 public WireframeSphere(final Point3D location, final float radius,
23 final LineAppearance lineFactory) {
26 final double step = Math.PI / 10;
28 final Point3D center = new Point3D();
32 for (double j = 0d; j <= (Math.PI * 2); j += step) {
34 Point3D oldPoint = null;
37 for (double i = 0; i <= (Math.PI * 2); i += step) {
38 final Point3D newPoint = new Point3D(0, 0, radius);
39 newPoint.rotate(center, i, j);
42 addShape(lineFactory.getLine(newPoint, oldPoint));
45 final Point3D previousRingPoint = previousRing
47 addShape(lineFactory.getLine(newPoint, previousRingPoint));
49 previousRing.set(pointIndex, newPoint);
51 previousRing.add(newPoint);