choice of parameters

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
devlaam
Posts: 19
Joined: Mon Oct 26, 2009 6:35 pm

choice of parameters

Post by devlaam »

After playing around with freecad for a few days it seems to me that the choice of parameters of the primitives is not very intuitive and generalizable. Maybe i missed features of the application, and in that case, please feel free to correct me. For example:

(1) If you want define a 45deg rotated cube inside and other cube somewhere not in the origin, you have a hard time, because of the translations you must calculate by hand. Rotation is always around a (possibly) self defined axis from the origin. However, the rotation needed is often not around the reference origin, but around some local origin.

(2) There exists a placement property on objects, for example the cube, which rotates first, and subsequently translates. This can hardly be called a property of such an object, but feels like an operator. Furthermore, the sequence of operations is fixed, and maybe confusing (at least to me it was)

(3) The parameters like width, height, length of the box may be appealing at first, but if the orientation of the created object matters, i keep making errors with respect to what parameters corresponds to what axis.

I would like to put forward a different system of parametrization and operation. Although, not complete yet, i think it would be better if
(1) Every primitive has a center of gravity, which acts as the local point of reference in a local frame of reference
(2) Dimensions of the object are parameterized with respect to that local origin.
(3) There exist an axis or rotation trough the local origin.
(4) There exists an point of external attachment (local origin per default)
(5) Positioning of the object is done by coupling the external attachment point to a point in the global frame of reference.
(6) Parametrization of an object may be done in multiple ways, that do not need to be independent. (sets)
(7) Parameter names are chose in such a way that inheritance of objects is made possible.
(8) Groups of objects have their own frame of reference, just like objects.

Operations are simply applying a new (local) frame of reference to object(s) and allow for translation, rotation, dilatation, fillets intersection etc.

Examples (loosely defined)

All Objects have the parameters:
external point of attachment (x,y,z)
rotation vector (x,y,z)
rotation angle (phi)

Box has an extra:
(set1) (x size, y size, z size) //the old with length height
(set2) (-x size, +x size, -y size, +y size , -z size, +z size)

Cube (can be defined as a derivative of box)
(set1) (size)
(set2) (half size)
(set3) (half diagonal)

Etc. I can refine this more if you like. In my opinion such a system makes is possible to write complicated objects directly in script without any mental acrobatics and without having to visualize every step using a gui.

But, again, maybe this is already all possible using python calls is do not yet know.

Ruud
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: choice of parameters

Post by jriegel »

Hi Ruud,
here my understanding of this topic:
devlaam wrote: (1) If you want define a 45deg rotated cube inside and other cube somewhere not in the origin, you have a hard time, because of the translations you must calculate by hand. Rotation is always around a (possibly) self defined axis from the origin. However, the rotation needed is often not around the reference origin, but around some local origin.
Sure the location of the origion is good/bad for a special purpose. I defined it out of the thinking that a CAD modeler needs the origion on the surface -
reachably by e.g. tactile measurement. But its always wrong or right from different stand points...

devlaam wrote: (2) There exists a placement property on objects, for example the cube, which rotates first, and subsequently translates. This can hardly be called a property of such an object, but feels like an operator. Furthermore, the sequence of operations is fixed, and maybe confusing (at least to me it was)
The Placement is NO operation, is the definition of Position (Vector3D) and Orientation (rotation) of an entity in FreeCAD. The problem you have is a lack
of functionality. We forget an operation on Placement which let you rotate around a arbitrary axis and point! Thats easy, I will do it with the 0.10!
See:
https://sourceforge.net/apps/mantisbt/f ... .php?id=33
https://sourceforge.net/apps/mantisbt/f ... p_page.php

With the rotation first I have to check! It would go against the intention of the Placement!

devlaam wrote: (3) The parameters like width, height, length of the box may be appealing at first, but if the orientation of the created object matters, i keep making errors with respect to what parameters corresponds to what axis.
A Feature is generally spoken a translator parameter -> shape. We can make a lot of them, with different parameters for producing primitives.
So its possible to make features with different origin and parameters.

For me its logic. If Z+ is the sky, parameters do exactly what they ment. We could call them XW,YX,ZW, but thats more for scripting and not for
modeling. The features are mainly for modeling. If you create shapes by script you better use Part.makeBox().
devlaam wrote: I would like to put forward a different system of parametrization and operation. Although, not complete yet, i think it would be better if
(1) Every primitive has a center of gravity, which acts as the local point of reference in a local frame of reference
(2) Dimensions of the object are parameterized with respect to that local origin.
(3) There exist an axis or rotation trough the local origin.
(4) There exists an point of external attachment (local origin per default)
(5) Positioning of the object is done by coupling the external attachment point to a point in the global frame of reference.
(6) Parametrization of an object may be done in multiple ways, that do not need to be independent. (sets)
(7) Parameter names are chose in such a way that inheritance of objects is made possible.
(8) Groups of objects have their own frame of reference, just like objects.

Operations are simply applying a new (local) frame of reference to object(s) and allow for translation, rotation, dilatation, fillets intersection etc.

Examples (loosely defined)

All Objects have the parameters:
external point of attachment (x,y,z)
rotation vector (x,y,z)
rotation angle (phi)

Box has an extra:
(set1) (x size, y size, z size) //the old with length height
(set2) (-x size, +x size, -y size, +y size , -z size, +z size)

Cube (can be defined as a derivative of box)
(set1) (size)
(set2) (half size)
(set3) (half diagonal)

Etc. I can refine this more if you like. In my opinion such a system makes is possible to write complicated objects directly in script without any mental acrobatics and without having to visualize every step using a gui.

But, again, maybe this is already all possible using python calls is do not yet know.
Very interesting system! Dont get me wrong - its a system you would like ;) I can give you a lot of opinions which would do it different.
But thats not my point! We in FreeCAD don't want to implement every possible system. Thats impossibly! What we want to do is lay
the foundation that all this systems can be made in FreeCAD.

e.g. in your case. We do this change in Placement i mentioned and than you shut be able to make a small python helper module which do
exactly what you want by translating parameters and calling Part.makeBox()and Placement.

That keeps the FreeCAD interface lightwight and every one can do his on creation style. If you donate your creation module to our code
base we would be happy!

And please understand, we can not change the FreeCAD interfaces to the fashion of the week. That would break to much code!
Nerveless I really appreciate your input! Its great that someone take the time and ask some tough questions. Its always good
to activate some brain cells! :)

Jürgen
Stop whining - start coding!
devlaam
Posts: 19
Joined: Mon Oct 26, 2009 6:35 pm

Re: choice of parameters

Post by devlaam »

Hello Jürgen,

First of all, thanks for your response and please see my post as the opinion of just one user. As you say correctly, there are a lot of other opinions, you cannot (and should not even try) to satisfy them all. I can see that, and i know that programmers, but noobs on FreeCad like me, always want to change the basics of the system, before they have even started :lol: It is just their nature. I have an open source project on Source Forge myself, Femto OS, so i know that users can put forward strange feature wishes completely ignoring the big picture and internals of the design.

On the other hand, (new) users not familiar with the design of a tool also have an unique perspective of the system, just because they do not know anything of the internals. They just want to get some work done, and realize they are hindered by some choices the designers made. I fall in this category regarding FreeCad. It is this i want to share with you.

Now i realize that i can always send in code and patches. I saw that for FreeCad you can add modules in Python, so maybe i can add my wishes and try them out, and if they work for me share them with the community. I get this invitation more often, so i occasionally send in patches to projects, but please realize it is simply not possible to start coding for every tool i work with. So the least i can do is post what difficulties i encounter, and try to point out a solution. Feel free to disagree or extend.

Now, to get back on topic, do you think it is possible to add my functionality without writing C++ code? Actually i am more comfortable in C/C++ then in python, but since the former requires a recompile, i better start with python modules first. I think the local rotation axis and the dependent sets will not pose a big problem, but will it also be possible to define a separate point for attachment and object grouping?

Ruud
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: choice of parameters

Post by jriegel »

Thanks for the understanding.
I see you understand the gravity in the FOSS world ;)

devlaam wrote: Now, to get back on topic, do you think it is possible to add my functionality without writing C++ code? Actually i am more comfortable in C/C++ then in python, but since the former requires a recompile, i better start with python modules first. I think the local rotation axis and the dependent sets will not pose a big problem, but will it also be possible to define a separate point for attachment and object grouping?
You can do nearly everything in Python in FreeCAD. Especially such things. And if not we will make it possible. The Python interface is our main handle
for "Power users". The C++ code of FreeCAD is vast and complicated. Its hard to get into it.

I talked to Werner, and I think we will change the Interface of Placement to make it more intuitive...

For the attachment and groups. As Yorik already said there is a planing to improve that topic. I plan a design where ever DocumentObject has the
ability to group. That makes it possible to use e.g. the PythonFeature to do special typed groups and write command for that.
Attachments are a little bit more tricky. Its delicate to have a parallel universe not recognized by the C++ part of FreeCAD. Im on the
standpoint that additional data shut be incorporated in derived soon classes with additional properties...
You can always use parallel data structures with a unique key of the DocumentObjects, but that data get not saved...

Another thing.
This kind of features you see at the moment are for me only a step to a real sketch based modeling approach. In that
approach you build your basic geometry out of an constraint sketch and use the features on a much higher level, like
complete bore holes and pattern. But thats on the way and only partial usably at the moment...

Jürgen
Stop whining - start coding!
Post Reply