Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cylinder rotation in Z axis #62

Open
skanga opened this issue Oct 7, 2020 · 0 comments
Open

Cylinder rotation in Z axis #62

skanga opened this issue Oct 7, 2020 · 0 comments

Comments

@skanga
Copy link

skanga commented Oct 7, 2020

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);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant