34 package eu.mihosoft.vrl.v3d;
36 import java.util.ArrayList;
37 import java.util.Arrays;
38 import java.util.List;
53 public Toroid(
double innerRadius,
double OuterRadius) {
54 this(innerRadius,OuterRadius,20,16);
56 public Toroid(
double innerRadius,
double OuterRadius,
int numSlices,
int facets) {
58 throw new RuntimeException(
"Inner radious must be positive");
59 if (innerRadius >= OuterRadius)
60 throw new RuntimeException(
"Outer radius must be larger than inner radius");
61 double crossSecRad = OuterRadius - innerRadius;
62 ArrayList<Vertex> vertices =
new ArrayList<>();
65 for (
int i = 0; i < facets; i++) {
67 double rad = index / f * 2 * Math.PI;
68 double a = Math.cos(rad) * crossSecRad;
69 double b = Math.sin(rad) * crossSecRad;
73 ArrayList<Polygon> slices =
new ArrayList<Polygon>();
75 for (
int i = 0; i < numSlices; i++) {
76 double angle = 360.0 / ((double) numSlices) * ((double) i);
79 List<Polygon> newPolygons =
new ArrayList<>();
80 for (
int j = 0; j < slices.size(); j++) {
82 if (next == slices.size())
86 Polygon polygon2=slices.get(next);
88 throw new RuntimeException(
"These polygons do not match");
91 int numvertices = polygon1.
vertices.size();
92 for (
int i = 0; i < numvertices; i++) {
94 int nexti = (i + 1) % numvertices;
101 List<Vector3d> pPoints = Arrays.asList(bottomV2, topV2, topV1, bottomV1);
final List< Vertex > vertices
static Polygon fromPoints(List< Vector3d > points, PropertyStorage shared)
PropertyStorage getStorage()
Polygon transformed(Transform transform)
List< Polygon > toPolygons()
Toroid(double innerRadius, double OuterRadius)
Toroid(double innerRadius, double OuterRadius, int numSlices, int facets)
final PropertyStorage properties
PropertyStorage getProperties()