@@ -59,23 +59,22 @@ const
5959 # # used internally by DegToRad and RadToDeg
6060
6161type
62- Matrix2d * = object
63- # # Implements a row major 2d matrix, which means
64- # # transformations are applied the order they are concatenated.
65- # # The rightmost column of the 3x3 matrix is left out since normally
66- # # not used for geometric transformations in 2d.
67- ax* ,ay* ,bx* ,by* ,tx* ,ty* :float
68- Point2d * = object
69- # # Implements a non-homogeneous 2d point stored as
70- # # an `x` coordinate and an `y` coordinate.
71- x* ,y* :float
72- Vector2d * = object
73- # # Implements a 2d **direction vector** stored as
74- # # an `x` coordinate and an `y` coordinate. Direction vector means,
75- # # that when transforming a vector with a matrix, the translational
76- # # part of the matrix is ignored.
77- x* ,y* :float
78- {.deprecated : [TMatrix2d : Matrix2d , TPoint2d : Point2d , TVector2d : Vector2d ].}
62+ Matrix2d * = object
63+ # # Implements a row major 2d matrix, which means
64+ # # transformations are applied the order they are concatenated.
65+ # # The rightmost column of the 3x3 matrix is left out since normally
66+ # # not used for geometric transformations in 2d.
67+ ax* ,ay* ,bx* ,by* ,tx* ,ty* :float
68+ Point2d * = object
69+ # # Implements a non-homogeneous 2d point stored as
70+ # # an `x` coordinate and an `y` coordinate.
71+ x* ,y* :float
72+ Vector2d * = object
73+ # # Implements a 2d **direction vector** stored as
74+ # # an `x` coordinate and an `y` coordinate. Direction vector means,
75+ # # that when transforming a vector with a matrix, the translational
76+ # # part of the matrix is ignored.
77+ x* ,y* :float
7978
8079
8180# Some forward declarations...
@@ -287,7 +286,7 @@ proc inverse*(m:Matrix2d):Matrix2d {.noInit.} =
287286 # # will be raised.
288287 let d= m.determinant
289288 if d== 0.0 :
290- raise newException (DivByZeroError ," Cannot invert a zero determinant matrix" )
289+ raise newException (ValueError ," Cannot invert a zero determinant matrix" )
291290
292291 result .setElements (
293292 m.by/ d,- m.ay/ d,
@@ -433,7 +432,7 @@ proc normalize*(v:var Vector2d) {.inline.}=
433432 # # Modifies `v` to have a length of 1.0, keeping its angle.
434433 # # If `v` has zero length, an EDivByZero will be raised.
435434 if not tryNormalize (v):
436- raise newException (DivByZeroError ," Cannot normalize zero length vector" )
435+ raise newException (ValueError ," Cannot normalize zero length vector" )
437436
438437proc transformNorm * (v:var Vector2d ,t:Matrix2d )=
439438 # # Applies a normal direction transformation `t` onto `v` in place.
@@ -449,7 +448,7 @@ proc transformNorm*(v:var Vector2d,t:Matrix2d)=
449448 # | | 0 0 1 | |
450449 let d= t.determinant
451450 if (d== 0.0 ):
452- raise newException (DivByZeroError ," Matrix is not invertible" )
451+ raise newException (ValueError ," Matrix is not invertible" )
453452 let newx = (t.by* v.x- t.ay* v.y)/ d
454453 v.y = (t.ax* v.y- t.bx* v.x)/ d
455454 v.x = newx
@@ -463,7 +462,7 @@ proc transformInv*(v:var Vector2d,t:Matrix2d)=
463462 let d= t.determinant
464463
465464 if (d== 0.0 ):
466- raise newException (DivByZeroError ," Matrix is not invertible" )
465+ raise newException (ValueError ," Matrix is not invertible" )
467466
468467 let newx= (t.by* v.x- t.bx* v.y)/ d
469468 v.y = (t.ax* v.y- t.ay* v.x)/ d
@@ -705,7 +704,7 @@ proc transformInv*(p:var Point2d,t:Matrix2d){.inline.}=
705704 # | TX TY 1 |
706705 let d= t.determinant
707706 if d== 0.0 :
708- raise newException (DivByZeroError ," Cannot invert a zero determinant matrix" )
707+ raise newException (ValueError ," Cannot invert a zero determinant matrix" )
709708 let
710709 newx= (t.bx* t.ty- t.by* t.tx+ p.x* t.by- p.y* t.bx)/ d
711710 p.y = - (t.ax* t.ty- t.ay* t.tx+ p.x* t.ay- p.y* t.ax)/ d
0 commit comments