You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The different resulting types of + and - for Point looks quite strange to me at the beginning...
It is understandable after a bit of thinking that - for point should result a "vector" as it means direction from p0 to p1.
However, as a basic geometry library, it is recommended to make types consistent across such basic math operations, rather than "interpret" it subjectively -- this may lead to unexpected errors and increase maintenance cost.
Case 2:
Another scenario may happen is when I have a p0 from some computation, and would like to use the corresponding v0 so that I can use methods in the compas.Vector class.
Currently there is no provided method in compas for doing sth like v0 = Vector(p0) or v0 = p0.CastToVector().
Recommendation
Perhaps such cases are due to a legacy where "type" was not considered as a first-class citizen in Python development...
I would however recommend to unify the types and make the computation more consistent.
For the math operations, following approach could be an option:
Make computation within each type constant.
Provide casting methods like v0 = p0.CastToVector(), or v0 = p0.CastToVector().
The text was updated successfully, but these errors were encountered:
I was also tripped by this in the past, however, it's more common than expected. In particular, Rhino SDK behaves the same:
And I think we discussed other libraries that also do the same, so it's not such an arbitrary decision.
Regarding the second point, it's already supported using list unpacking syntax (which could be claimed is more pythonic than cast_to_vector() which looks very much like C#/static-typing language):
Case 1:
In the documentation: https://compas.dev/compas/latest/userguide/basics.geometry.points_and_vectors.html
We have:
The different resulting types of
+
and-
forPoint
looks quite strange to me at the beginning...It is understandable after a bit of thinking that
-
for point should result a "vector" as it means direction fromp0
top1
.However, as a basic geometry library, it is recommended to make types consistent across such basic math operations, rather than "interpret" it subjectively -- this may lead to unexpected errors and increase maintenance cost.
Case 2:
Another scenario may happen is when I have a
p0
from some computation, and would like to use the correspondingv0
so that I can use methods in thecompas.Vector
class.Currently there is no provided method in
compas
for doing sth likev0 = Vector(p0)
orv0 = p0.CastToVector()
.Recommendation
Perhaps such cases are due to a legacy where "type" was not considered as a first-class citizen in Python development...
I would however recommend to unify the types and make the computation more consistent.
For the math operations, following approach could be an option:
type
constant.v0 = p0.CastToVector()
, orv0 = p0.CastToVector()
.The text was updated successfully, but these errors were encountered: