Skip to content

Commit ad0d0f6

Browse files
committed
fix for issue #24 : #24
1 parent 38f8a6f commit ad0d0f6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/main/java/eu/mihosoft/vrl/v3d/RoundedCube.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public RoundedCube(Vector3d center, Vector3d dimensions) {
5959
}
6060

6161
/**
62-
* Constructor. Creates a new rounded cuboid with center {@code [0,0,0]}
63-
* and with the specified dimensions.
62+
* Constructor. Creates a new rounded cuboid with center {@code [0,0,0]} and
63+
* with the specified dimensions.
6464
*
6565
* @param w width
6666
* @param h height
@@ -70,11 +70,10 @@ public RoundedCube(double w, double h, double d) {
7070
this(Vector3d.ZERO, new Vector3d(w, h, d));
7171
}
7272

73-
7473
@Override
7574
public List<Polygon> toPolygons() {
76-
CSG spherePrototype =
77-
new Sphere(getCornerRadius(), getResolution()*2, getResolution()).toCSG();
75+
CSG spherePrototype
76+
= new Sphere(getCornerRadius(), getResolution() * 2, getResolution()).toCSG();
7877

7978
double x = dimensions.x / 2.0 - getCornerRadius();
8079
double y = dimensions.y / 2.0 - getCornerRadius();
@@ -94,6 +93,12 @@ public List<Polygon> toPolygons() {
9493
sphere2, sphere3, sphere4,
9594
sphere5, sphere6, sphere7, sphere8).hull().getPolygons();
9695

96+
Transform locTransform = Transform.unity().translate(center);
97+
98+
for (Polygon p : result) {
99+
p.transform(locTransform);
100+
}
101+
97102
if (!centered) {
98103

99104
Transform centerTransform = Transform.unity().translate(dimensions.x / 2.0, dimensions.y / 2.0, dimensions.z / 2.0);
@@ -141,6 +146,7 @@ public void setDimensions(Vector3d dimensions) {
141146

142147
/**
143148
* Defines that this cube will not be centered.
149+
*
144150
* @return this cube
145151
*/
146152
public RoundedCube noCenter() {
@@ -161,8 +167,8 @@ public int getResolution() {
161167
public void setResolution(int resolution) {
162168
this.resolution = resolution;
163169
}
164-
165-
/**
170+
171+
/**
166172
* @param resolution the resolution to set
167173
* @return this cube
168174
*/
@@ -184,7 +190,7 @@ public double getCornerRadius() {
184190
public void setCornerRadius(double cornerRadius) {
185191
this.cornerRadius = cornerRadius;
186192
}
187-
193+
188194
/**
189195
* @param cornerRadius the corner radius to set
190196
* @return this cube

0 commit comments

Comments
 (0)