pmc/pmc.cc
changeset 4 236f8f747073
child 9 c3fecc82ade6
equal deleted inserted replaced
3:820ed7fb9314 4:236f8f747073
       
     1 /***
       
     2  *
       
     3  * $Id: pmc.cc,v 1.1.1.1 2008-04-28 17:33:22 mbroeker Exp $
       
     4  * $Source: /development/cpp/pmc/pmc.cc,v $
       
     5  *
       
     6  */
       
     7 
       
     8 #include <iostream>
       
     9 #include <cmath>
       
    10 #include <pmc.h>
       
    11 
       
    12 using namespace pmc;
       
    13 
       
    14 Vector::Vector (int xx, int yy, int zz)
       
    15 {
       
    16     name = "Vector";
       
    17     x = xx;
       
    18     y = yy;
       
    19     z = zz;
       
    20     mode = RAD;
       
    21 }
       
    22 
       
    23 Vector::~Vector ()
       
    24 {
       
    25 }
       
    26 
       
    27 int Vector::X ()
       
    28 {
       
    29     return x;
       
    30 }
       
    31 
       
    32 int Vector::Y ()
       
    33 {
       
    34     return y;
       
    35 }
       
    36 
       
    37 int Vector::Z ()
       
    38 {
       
    39     return z;
       
    40 }
       
    41 
       
    42 Vector Vector::operator+ (Vector a)
       
    43 {
       
    44     return Vector (x + a.X (), y + a.Y (), z + a.Z ());
       
    45 }
       
    46 
       
    47 Vector Vector::operator- (Vector a)
       
    48 {
       
    49     return Vector (x - a.X (), y - a.Y (), z - a.Z ());
       
    50 }
       
    51 
       
    52 int Vector::operator* (Vector a)
       
    53 {
       
    54     return (x * a.X () + y * a.Y () + z * a.Z ());
       
    55 }
       
    56 
       
    57 double Vector::abs ()
       
    58 {
       
    59     return (std::sqrt (x * x + y * y + z * z));
       
    60 }
       
    61 
       
    62 void Vector::vector ()
       
    63 {
       
    64     std::cout << "(" << x << ", " << y << ", " << z << ")";
       
    65 }
       
    66 
       
    67 double Vector::angle (Vector p)
       
    68 {
       
    69     if (mode == DEG)
       
    70         return ((180.0 / M_PI) * std::acos ((p ** this) / (abs () * p.abs ())));
       
    71 
       
    72     return (std::acos ((p ** this) / (abs () * p.abs ())));
       
    73 }
       
    74 
       
    75 void Vector::setMode (Mode m)
       
    76 {
       
    77     mode = m;
       
    78 }