Merge: Annotation lateinit
[nit.git] / lib / geometry / points_and_lines.nit
index 492d31f..6c7fda6 100644 (file)
@@ -33,12 +33,6 @@ class Point[N: Numeric]
 
        redef var x: N
        redef var y: N
-
-       init(x, y: N)
-       do
-               self.x = x
-               self.y = y
-       end
 end
 
 # An abstract 3d point, strongly linked to its implementation `Point3d`
@@ -57,19 +51,17 @@ class Point3d[N: Numeric]
        super Point[N]
 
        redef var z: N
-
-       init(x, y, z: N)
-       do
-               super
-               self.z = z
-       end
 end
 
 # An abstract 2d line segment
 interface ILine[N: Numeric]
+       # The type of points that ends the segment
        type P: IPoint[N]
 
+       # The point that is the left-end of the segment
        fun point_left: P is abstract
+
+       # The point that is the right-end of the segment
        fun point_right: P is abstract
 
        redef fun to_s do return "{point_left}--{point_right}"
@@ -79,15 +71,14 @@ end
 class Line[N: Numeric]
        super ILine[N]
 
-       redef var point_left: P
-       redef var point_right: P
+       redef var point_left
+       redef var point_right
 
-       init(a, b: P)
+       init
        do
-               if a.x < b.x then
-                       point_left = a
-                       point_right = b
-               else
+               var a = point_left
+               var b = point_right
+               if a.x > b.x then
                        point_left = b
                        point_right = a
                end