Skip to content

Commit 2471798

Browse files
committed
fixed profile correction (orientation palne)
1 parent 9d23258 commit 2471798

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

gradle/project-info.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// -----------------------------------------------------------------------------
44
ext.publishing.artifactId = project.name.toLowerCase()
55
ext.publishing.groupId = 'eu.mihosoft.jcsg.ext.path'
6-
ext.publishing.versionId = '0.2.4'
6+
ext.publishing.versionId = '0.2.5'
77

88
ext.publishing.developerName = 'Michael Hoffer'
99
ext.publishing.developerAlias = 'miho'

src/main/java/eu/mihosoft/jcsg/ext/path/ExtrudeProfile.java

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,9 @@ private static CSG extrudeSegments(PathProfile profile,
227227

228228
List<Polygon> polygons = new ArrayList<>();
229229

230+
// correction angle (used if plane specified)
230231
double angleToPlaneNormal = 0;
231232

232-
if(orientationPlane !=null) {
233-
// compute angle between edge (v0,v1) of the profile and
234-
// the normal of the specified orientation-plane
235-
angleToPlaneNormal = profilePoints.get(0).minus(profilePoints.get(1)).
236-
angle(orientationPlane.getNormal());
237-
}
238-
239233
for (int i = 0; i < segments.size(); i++) {
240234
Segment s = segments.get(i);
241235

@@ -296,40 +290,43 @@ private static CSG extrudeSegments(PathProfile profile,
296290
profilePointsTransformed.add(p);
297291
}
298292

293+
//perform correction if orientation plane has been specified
299294
if(orientationPlane!=null) {
300-
301295
// compute angle between current profile edge (v0, v1) and
302296
// the normal of the orientation-plane
303297
double angleToPlaneNormalNew = profilePointsTransformed.get(0).
304298
minus(profilePointsTransformed.get(1))
305299
.angle(orientationPlane.getNormal());
306300

307-
// for undoing the rotation with respect to the reference angle
308-
// 'angleToPlaneNormal' we subtract the current angle from
309-
// the reference angle
310-
double angleToRot = angleToPlaneNormal - angleToPlaneNormalNew;
301+
if(Double.compare(angleToPlaneNormal, 0.0) ==0) {
302+
angleToPlaneNormal = angleToPlaneNormalNew;
303+
} else {
304+
// for undoing the rotation with respect to the reference angle
305+
// 'angleToPlaneNormal' we subtract the current angle from
306+
// the reference angle
307+
double angleToRot = angleToPlaneNormal - angleToPlaneNormalNew;
311308

312-
// define the rotation about curve tangent
313-
Transform corrRot = Transform.unity().
314-
rot(s.getPos(), s.getNormal(), angleToRot);
309+
// define the rotation about curve tangent
310+
Transform corrRot = Transform.unity().
311+
rot(s.getPos(), s.getNormal(), -angleToRot);
315312

316-
List<Vector3d> profilePointsTransformedCorr
317-
= new ArrayList<>(profilePointsTransformed.size());
313+
List<Vector3d> profilePointsTransformedCorr
314+
= new ArrayList<>(profilePointsTransformed.size());
318315

319-
// finally apply the correction transforms
320-
for (Vector3d p : profilePointsTransformed) {
321-
// apply rotation transform
322-
p = p.transformed(corrRot);
316+
// finally apply the correction transforms
317+
for (Vector3d p : profilePointsTransformed) {
318+
// apply rotation transform
319+
p = p.transformed(corrRot);
323320

324-
// add transformed point to list
325-
profilePointsTransformedCorr.add(p);
326-
}
321+
// add transformed point to list
322+
profilePointsTransformedCorr.add(p);
323+
}
327324

328-
profilePointsTransformed =
329-
new ArrayList<>(profilePointsTransformedCorr);
325+
profilePointsTransformed = profilePointsTransformedCorr;
326+
}
330327
}
331328

332-
// combine both profile profiles and close start and end to
329+
// combine both profiles and close start and end to
333330
// yield a valid CSG object
334331
CSG csg = CSG.fromPolygons(Extrude.combine(
335332
Polygon.fromPoints(profilePoints),

0 commit comments

Comments
 (0)