pmc/vector.cc
changeset 43 cf8c1b5127b2
parent 42 83b8151b966d
child 45 7197576fedcf
equal deleted inserted replaced
42:83b8151b966d 43:cf8c1b5127b2
    35 int Vector::Y ()
    35 int Vector::Y ()
    36 {
    36 {
    37     return y;
    37     return y;
    38 }
    38 }
    39 
    39 
    40 Vector Vector::operator+ (Vector a)
    40 Vector Vector::operator+ (Vector& a)
    41 {
    41 {
    42     return Vector (x + a.X (), y + a.Y ());
    42     return Vector (x + a.X (), y + a.Y ());
    43 }
    43 }
    44 
    44 
    45 Vector Vector::operator- (Vector a)
    45 Vector Vector::operator- (Vector& a)
    46 {
    46 {
    47     return Vector (x - a.X (), y - a.Y ());
    47     return Vector (x - a.X (), y - a.Y ());
    48 }
    48 }
    49 
    49 
    50 double Vector::abs ()
    50 double Vector::abs ()
    55 void Vector::vector ()
    55 void Vector::vector ()
    56 {
    56 {
    57     fprintf (stderr, "(%.3d, %.3d)", x, y);
    57     fprintf (stderr, "(%.3d, %.3d)", x, y);
    58 }
    58 }
    59 
    59 
    60 double Vector::angle (Vector v)
    60 double Vector::angle (Vector& v)
    61 {
    61 {
    62     if (mode == DEG)
    62     if (mode == DEG)
    63         return ((180.0 / M_PI) * std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ())));
    63         return ((180.0 / M_PI) * std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ())));
    64 
    64 
    65     return (std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ())));
    65     return (std::acos ((v.X () * X () + v.Y () * Y ()) / (abs () * v.abs ())));