Update for GEllipse#1
Update for GEllipse#1akevalion wants to merge 7 commits intopharo-contributions:masterfrom akevalion:master
Conversation
| or := (point1 x min: point2 x) , (point1 y min: point2 y). | ||
| cor := (point1 x max: point2 x) , (point1 y max: point2 y). | ||
|
|
||
| or = cor ifTrue: [ self error: 'This is not a rectangle but a point.' ]. |
There was a problem hiding this comment.
In which case do you want a rectangle that is a point?
There was a problem hiding this comment.
I've checked and from the mathematical point of view a point cannot be considered as a rectangle.
There was a problem hiding this comment.
What is your reference? From my perspective, users can have empty shapes like an empty ellipse or empty rectangles, or empty polygons.
There was a problem hiding this comment.
I checked multiple sources such as Wikipedia, Wolfram, the dictionary...
All of them agree on "quadrilateral with opposite sides of equal lengths a and b, and with four right angles"
A point cannot have right angles. Thus, a point is not a rectangle.
There was a problem hiding this comment.
I rollback this method to its previous version
There was a problem hiding this comment.
For empty shapes, I would create a NullShape. For intersections, for example, it would always return an empty collection.
Or if your empty shape acts as a point, then I would use a point instead. IIRC points can react to #intersections:
There was a problem hiding this comment.
I will use points for that then.
suggested by @jecisc Co-authored-by: CyrilFerlicot <cyril@ferlicot.me>
| ] | ||
|
|
||
| { #category : #tests } | ||
| GEllipseTest >> testEmpty [ |
There was a problem hiding this comment.
Oh, so the code managed ellispes without vertexes.
I think we are in the same case of the rectangle, those are not ellispses.
An ellipse is a curve that is the locus of all points in the plane the sum of whose distances r_1 and r_2 from two fixed points F_1 and F_2 (the foci) separated by a distance of 2c is a given positive constant 2a (Hilbert and Cohn-Vossen 1999, p. 2).
An ellipse needs a curve, which is not possible when there are no vertexes :(
There was a problem hiding this comment.
For roassal when shapes were empty I will use points
There was a problem hiding this comment.
Maybe the constructors of GRectangle and GEllipse can return a point instead of an error
…sToBeInComparingProtocol Because Roassal3 uses last version of geometry
Update distanceTo: for GSegment
Added