Skip to content

Cylinder rotation in Z axis #62

Description

@skanga

Can anyone tell me whether cylinder rotation in Z axis is working or not?

It seems to fail for me - not sure if I'm doing something wrong.

In this example I am trying to build a square pyramid out of cylindrical poles and can't get it to work at all. Any thoughts?

This is my test code.

import eu.mihosoft.jcsg.CSG;
import eu.mihosoft.jcsg.Cylinder;
import eu.mihosoft.jcsg.FileUtil;
import eu.mihosoft.vvecmath.Transform;

import java.io.IOException;
import java.nio.file.Paths;

public class PoleTest
{
    public static void main(String[] args) throws IOException
    {
        CSG result = new PoleTest().toCSG();
        FileUtil.write(Paths.get("PoleTest.stl"), result.toStlString());
    }

    public CSG pole(double length, double radius, double rotX, double rotY, double rotZ, double trX, double trY, double trZ)
    {
        System.out.printf("rotX=%.2f rotY = %.2f rotZ = %.2f%n", rotX, rotY, rotZ);
        CSG innerCyl = new Cylinder(radius, length, 16).toCSG();
        return innerCyl.transformed(Transform.unity().rotX(rotX).rotY(rotY).rotZ(rotZ))
            .transformed(Transform.unity().translate(trX, trY, trZ));
    }

    public CSG toCSG()
    {
        double armLength = 150;
        double armRadius = 5;

        CSG pole1 = pole(armLength, armRadius,0, 60,0, 0,0,45);
        CSG pole2 = pole(armLength*2, armRadius,30, 45,45, armLength, 0, 0);
        CSG pole3 = pole(armLength, armRadius,45, 0,90, 0, armLength,0);
        CSG pole4 = pole(armLength, armRadius,45, 90,0, armLength,armLength,0);
        return pole1.union(pole2).union(pole3).union(pole4);
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions