Skip to content

Commit

Permalink
fix for issue #24 : #24
Browse files Browse the repository at this point in the history
  • Loading branch information
miho committed Nov 8, 2016
1 parent 38f8a6f commit ad0d0f6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/main/java/eu/mihosoft/vrl/v3d/RoundedCube.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public RoundedCube(Vector3d center, Vector3d dimensions) {
}

/**
* Constructor. Creates a new rounded cuboid with center {@code [0,0,0]}
* and with the specified dimensions.
* Constructor. Creates a new rounded cuboid with center {@code [0,0,0]} and
* with the specified dimensions.
*
* @param w width
* @param h height
Expand All @@ -70,11 +70,10 @@ public RoundedCube(double w, double h, double d) {
this(Vector3d.ZERO, new Vector3d(w, h, d));
}


@Override
public List<Polygon> toPolygons() {
CSG spherePrototype =
new Sphere(getCornerRadius(), getResolution()*2, getResolution()).toCSG();
CSG spherePrototype
= new Sphere(getCornerRadius(), getResolution() * 2, getResolution()).toCSG();

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

Transform locTransform = Transform.unity().translate(center);

for (Polygon p : result) {
p.transform(locTransform);
}

if (!centered) {

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

/**
* Defines that this cube will not be centered.
*
* @return this cube
*/
public RoundedCube noCenter() {
Expand All @@ -161,8 +167,8 @@ public int getResolution() {
public void setResolution(int resolution) {
this.resolution = resolution;
}
/**

/**
* @param resolution the resolution to set
* @return this cube
*/
Expand All @@ -184,7 +190,7 @@ public double getCornerRadius() {
public void setCornerRadius(double cornerRadius) {
this.cornerRadius = cornerRadius;
}

/**
* @param cornerRadius the corner radius to set
* @return this cube
Expand Down

0 comments on commit ad0d0f6

Please sign in to comment.