pmc/pmc.cc
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:57:59 +0100
changeset 7 a1aa30f0f904
parent 4 236f8f747073
child 9 c3fecc82ade6
permissions -rw-r--r--
libtest demonstrates how to use shared libraries committer: Markus Bröker <mbroeker@largo.homelinux.org>

/***
 *
 * $Id: pmc.cc,v 1.1.1.1 2008-04-28 17:33:22 mbroeker Exp $
 * $Source: /development/cpp/pmc/pmc.cc,v $
 *
 */

#include <iostream>
#include <cmath>
#include <pmc.h>

using namespace pmc;

Vector::Vector (int xx, int yy, int zz)
{
    name = "Vector";
    x = xx;
    y = yy;
    z = zz;
    mode = RAD;
}

Vector::~Vector ()
{
}

int Vector::X ()
{
    return x;
}

int Vector::Y ()
{
    return y;
}

int Vector::Z ()
{
    return z;
}

Vector Vector::operator+ (Vector a)
{
    return Vector (x + a.X (), y + a.Y (), z + a.Z ());
}

Vector Vector::operator- (Vector a)
{
    return Vector (x - a.X (), y - a.Y (), z - a.Z ());
}

int Vector::operator* (Vector a)
{
    return (x * a.X () + y * a.Y () + z * a.Z ());
}

double Vector::abs ()
{
    return (std::sqrt (x * x + y * y + z * z));
}

void Vector::vector ()
{
    std::cout << "(" << x << ", " << y << ", " << z << ")";
}

double Vector::angle (Vector p)
{
    if (mode == DEG)
        return ((180.0 / M_PI) * std::acos ((p ** this) / (abs () * p.abs ())));

    return (std::acos ((p ** this) / (abs () * p.abs ())));
}

void Vector::setMode (Mode m)
{
    mode = m;
}