Hi all,
It would be great if you can comment on the upcoming API for the 3D
geometry module.
The current module has a nice class structure for 2D objects (points,
planar figures, conics) and does not support anything in 3D.
For the moment this is the approach taken to extending it to 3D. It
nicely minimizes code duplication, but something does not seem right
to me.
- class Point3D
- it receives 2 or 3 coordinates on creation
- 2 points means that the last one is set to zero by default
- it has all the fancy methods to find midpoints, create lines, etc.
- class Point (it is Point2D, but for backward compatibility is called
just Point)
- subclass of Point3D
- it is a very shallow subclass of Point3D where the last coordinate
is set to 0
- it has a method to convert to a 3D point and most of the
calculations are done with it
pros:
- very little code duplication
cons:
- a lot of `if isinstance` inside the Point3D code to check and
convert Point to Point3D
- Point and Point3D seem unnecessarily tightly coupled
- I do not like how a lot of the classification whether something is
3d or 2d is done by checking the number of coordinates (implicitly)
and not by classes (explicitly)
I think a better approach would be to not touch `Point` at all, and
implement Point3D independently. This will require some minor code
duplication. However total length of code will not be higher and the
code will be much easier to understand. Compare this to right now:
there are a lot of `isinstance` checks in the base implementation of
most methods, which is a serious antipattern.
When this is done we can see whether it makes sense to abstract
anything in a base class.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAD8szLy%3DazQhBt-a-ouq9Ynh7ner2Fp76B2FkBGEdxGwPS0X9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.