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

Rotation is always about the world origin #2

Open
FacticiusVir opened this issue Apr 3, 2017 · 1 comment
Open

Rotation is always about the world origin #2

FacticiusVir opened this issue Apr 3, 2017 · 1 comment

Comments

@FacticiusVir
Copy link

For the following

Lot --> extrude(1)
        s(5, 1, 1)
        split(x) {1: A | 1: NIL | 1: B | 1: NIL | 1: C}

A --> color("red")

B --> color("green")

C --> color("blue")
        r(0, 45, 0)

I intended C to be in line with A & B, but rotated 45 degrees about its centre; instead, it is rotated about the world origin and moves out of line. I have to translate C to the origin, rotate and translate back to simulate the intended effect:

Lot --> extrude(1)
        s(5, 1, 1)
        split(x) {1: A | 1: NIL | 1: B | 1: NIL | 1: C}

A --> color("red")

B --> color("green")

C --> color("blue")
        t(-4.5, 0, 0.5)
        r(0, 45, 0)
        t(4.5, 0, -0.5)

(Also note that the translation to origin has 0.5 X & Z offsets, as lots are not centred on the world origin)

@gromgull
Copy link
Owner

gromgull commented Apr 4, 2017

Hey! and thanks for playing with cgajs!

Yeah - the rotation is certainly annoying. It is however on purpose, since this is what the CGA reference dictates. Rotation by default is around the pivot, which is in the "bottom left" corner of each object: http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/manual/cga/shape_operations/cga_so_trans_coordinatesystems.html

What could be improved in my implementation though is to allow you to override the rotation center: https://esri.github.io/esri-cityengine-sdk/html/cgaref/cgareference/op_r.html

or implement setPivot or any of the others ways of moving the pivot for each shape.

I'll have a look!

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

2 participants