jscad / csg.js

DEPRECATED: CSG Library for JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/master/packages/modeling
MIT License
217 stars 56 forks source link

V2 : Add center parameter to cylinderElliptic / cylinder primitives #180

Closed z3dev closed 3 years ago

z3dev commented 5 years ago

While converting some examples to V2, it became apparent that centering of cylinders would simplify the creation of designs. In addition, other primitives have center, so adding centering to cylinders normalizes the parameters to primitives.

cylinderElliptic:

cylinder: (alias to cylinderElliptic)

z3dev commented 5 years ago

@kaosat-dev ... I like the idea of removing the center parameter from the primitives. Removing the center parameter will simplify the definitions for each primitive, which will help later in future plans. In addition, the center function as well as the translate functions are easily available.

Thoughts?

kaosat-dev commented 5 years ago

@z3dev as said in hangouts, I do think that is the way forward, BUT is there any case where we need to store the center in the primitives data for any reason (I cannot think of any valid reason to do so)

z3dev commented 5 years ago

I don't think there's any reason to store the center information as part of the primitives definition. We just need to be consistent that all primitives are 'centered' at the axis, always. This is required for symetric rotations anyway.

I think we should consider a few more measurements just to help the users. See Issue #23

kaosat-dev commented 5 years ago

@z3dev the default positioning for cubes etc is not centered sadly (thanks to openscad) , but 100% agreed otherwise. In addition to the measurements (I agree with all of them) we also need (I have pre-existing code too)

z3dev commented 5 years ago

Cool. I’ll open new issues for all of the new functionality, one for each. And mark them for V2.

I suggest we just leave center parameters in for now, and write code and examples that use the new functionality. And, if all goes well, the center parameters are removed.

How do you want to proceed?

kaosat-dev commented 5 years ago

So you mean adding an issue for 'removal of center' , closing this pr and remove the centers in a later pass ?

z3dev commented 5 years ago

Correct. Let’s remove center in the cleanup pass. Coming soon?

z3dev commented 5 years ago

Hmm... here’s one reason for keeping center in the primitives. SVG defines circle / ellipses / etc. with a center.

<rect x="80" y="60" width="250" height="250" rx="20"/>

z3dev commented 5 years ago

Autocad DXF also has the concept of center point for some ‘entities’.

20, 30 DXF: Y and Z values of center point

kaosat-dev commented 5 years ago

For svg that is just a position/ translation in the end right ? Dxf i dunno The thing is we do not have concepts of centers for 90% of the primitives (because it does not make sense for most of them). Here it is also only a parameter that is making a shorthand for primitive + translate. So i think our previous discussion about not keeping them is stil valid. (unless we get back into geometry vs transforms, haha :-)

z3dev commented 5 years ago

agreed. now that all primitives are created 'centered on the axis'. we can translate easily.

kaosat-dev commented 5 years ago

@z3dev cool, glad we agree on simplying :D, so what shall we do with this PR ?

z3dev commented 5 years ago

Closing this PR based on discussions. I will save the code until V2 is done and dusted.

z3dev commented 4 years ago

Sorry. I re-opened this pull request as I think there may be a good reason to include 'center' in primitives.

As we move forward from V2, the vision is moving to an 'expressive' set of primitives, which can have several implementations underneath. However, the expressive primitives need to be 'transformable'. In other words, the basic transforms can apply to the expressive primitives, if the position of the expressive primitive is known.

let geometry = circle({radius: 10, center: [-5, 10]})
geometry = geometry.translate([5, 5]) // translate can be applied to the expressive primitive
geometry = geometry.scale([0.5, 2.0]) // scale can be applied to the expressive primitive!

I just wanted to bring this up for discussion before putting this to sleep.

@kaosat-dev Thoughts?

z3dev commented 4 years ago

@kaosat-dev sorry, but I think this should go into V2. From the conceptual standpoint, translation should be separate, but...

From the user point of view, centering a shape is easy, and easy to calculate as well From the performance point, only one function to create and place the shape From the stack point, only one data model, not two

I’d really like this to be part of V2.

kaosat-dev commented 4 years ago

@z3dev Sorry, I should have answered here as well last time and not just on hangouts. I have to dissagree on this, sorry: imho it is not just about adding an extra parameter into ever single primitive, this is really the same discussion as with transforms:

From the performance point, only one function to create and place the shape

No, under the hood, it is still multiple operations at some point or another :)

From the stack point, only one data model, not two not sure I understand ?

z3dev commented 3 years ago

Closing as this was PR is part of V2.