Reformating discussion to adapt to 2D-like sketching #96
Replies: 8 comments 5 replies
-
That is not totally right @jorgepiloto. We have a
These classes also have embedded support for knowing its dimensions. You can run We moved from the specific Plus, in terms of usability, it is again easier to just call |
Beta Was this translation helpful? Give feedback.
-
Regarding the proper override of the dunder methods in the |
Beta Was this translation helpful? Give feedback.
-
I agree that the |
Beta Was this translation helpful? Give feedback.
-
FYI, if I remember properly, the Eigen library is using something similar to dynamic aliases for noting VectorXD. It is the same class behind the scenes - with dynamic dimensions. The only difference is that it accepts instantiating it as Vector3D |
Beta Was this translation helpful? Give feedback.
-
circle = sketch.draw_circle(
center=Point2D(xy=(0, 0), units=u.mm),
radius=Distance(magnitude=1, units=u.mm)
) Point2D creates more usable signatures for using the Sketch class IMO. In the current signature, it is ambiguous whether a 3rd dimension is expected or not. A 2D point is a different coordinate system from the 3D point in this context even though they are the same method parameter. It would be much cleaner to restrict to 2D via a type since the sketch is a planar perspective. |
Beta Was this translation helpful? Give feedback.
-
I also agree with consistency in Ansys projects. Every project I have seen so far has 2D and 3D specific types for Point/Vector/Matrix, including the underlying service we are wrapping. Users could adopt our tool faster/better if the naming conventions are inline with SpaceClaim. |
Beta Was this translation helpful? Give feedback.
-
Whelp. If I'm the only against it, then go ahead 😄 ... Honestly I think we are going to fall back into the same issue we had before (which was having numerous duplicated concepts and classes, repeated implementations, functionalities and so on). If you align everything to The constructor for Point and Vector, as it is right now, works perfectly fine for both concepts. If a user provided 2 values it will behave as 2D. If the user provided 3 values it behaves as 3D. And It will always stay like that since (again) once you instantiate a numpy.ndarray it stays the same in terms of dimensions. I can understand your reasons for 'clarifying' the interface, but honestly... I think it's the same thing and we will be duplicating everything. So I don't really see the benefit here. BTW, SpaceClaim uses the sole concept of "Point" for example. They don't make any distinctions at "naming" AFAIK.... It's just "Point" |
Beta Was this translation helpful? Give feedback.
-
Reformatting has been performed. Pure 2D sketching is now implemented. Thank you all for your collaboration. I am now locking this discussion. |
Beta Was this translation helpful? Give feedback.
-
🐞 Problem
Due to short timelines, we ended up developing quite fast till we finally came with the minimum required logic.
As of now, the
ansys.geometry.core.sketch
module assumes users to be working in the 3D global frame. As we already now, this complicates things, as we need to perform various checks to guarantee that the points of the sketch belong to its fundamental plane.Although the reformat may seem easy, there are various things behind the scenes that need to be refactored first to successfully get a robust and solid implementation of the sketch side.
💡 Naming conventions
Right now, our
ansys.geometry.core.math
objects are not consistent in naming. We havePoint
,Vector
andMatrix33
. I would like to suggest the following naming conventions:Point
,Point2D
andPoint3D
Vector
,Vector2D
andVector3D
Matrix
,Matrix2D
andMatrix3D
The following functions would be implemented, returning
Matrix2D
orMatrix3D
:get_rotation_matrix2D(angle)
androtation_matrix3D(angle, axis)
get_translation_matrix2D(Vector2D)
andtranslation_matrix3D(Vector3D)
get_scaling_matrix2D(fx, fy)
andget_scaling_matrix3D(fx, fy, fz)
These follow the naming of libraries like Eigen, C++. Notice that I suggested to bring back the 2D and 3D classes. This is has several advantages:
Previous naming conventions would allow us to support a C#-like (strongly typed) approach:
Pythonic support
Strongly typed support (C#-like)
Notice that right now, the following needs to be done:
💡 Remove setters
The reason behind this suggestion is to force users to pass through constructors and transformations to modify the objects they create.
💡 Proper overriding of matrix multiplication methods
There are two big dunder methods that apply when using the
*
and@
operators:__mul__
allows to override the*
method__matmul
is for matrix multiplication and allows to override the@
operatorWe need to ensure that both methods are overriden and return our custom objects. Otherwise, we sometimes get
np.ndarrays
instead of our own objects.💡 Using transformations in sketch objects
All shapes inheriting from
BaseShape
should implement therotate
,scale
andtranslate
methods. These would call the routinesget_translation_matrix2D
,get_rotation_matrix2D
andget_translation_matrix2D
behind the scenes to perform the requested transformation.On the other hand, the
Sketch
class could implement therotate
,scale
andtranslate
methods too but from a 3D perspective. Here is where theget_*_matrix3D
logic would be used.Beta Was this translation helpful? Give feedback.
All reactions