/***************************************************************************
 *   Copyright (C) 2006 by Harish Kukreja                                  *
 *   harish.kukreja@gmail.com                                              *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

//
// C++ Implementation: objects
//
// Description: Definitions of various physical Objects that are found in the Physiks interactions
//              environment.
//
// Author: Harish Kukreja <harish.kukreja@gmail.com>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//


#include "objects.h"

using Physiks::Vector;


// Definitions for Physiks::PhysicalObject ////////////////////////////////

Physiks::PhysicalObject::PhysicalObject() : 
  mass(0.0), charge(0.0), position(3, 0.0), velocity(3, 0.0) {}

Physiks::PhysicalObject::PhysicalObject(const PhysicalObject &part) : 
  mass(part.mass), charge(part.charge), position(part.position), velocity(part.velocity) {}

Physiks::PhysicalObject::PhysicalObject(PHYSCALAR m, PHYSCALAR c, const Vector &pos, 
    const Vector &vel) : mass(m), charge(c), position(pos), velocity(vel) {}

Physiks::PhysicalObject::~PhysicalObject() {}



// Definitions for Physiks::RigidBody ////////////////////////////////

Physiks::RigidBody::RigidBody() : PhysicalObject(), angular_velocity(3, 0.0) {}

Physiks::RigidBody::RigidBody(PHYSCALAR m, PHYSCALAR c, const Vector &pos, const Vector &vel, 
    const Vector &ang_vel) : PhysicalObject(m, c, pos, vel), angular_velocity(3, 0.0) {}

Physiks::RigidBody::RigidBody(const RigidBody &obj) : 
  PhysicalObject(obj), angular_velocity(obj.angular_velocity) {}

Physiks::RigidBody::~RigidBody() {}


// Definitions for Physiks::Sphere ////////////////////////////////////////

Physiks::Sphere::Sphere() : RigidBody(), radius(1.0) {}

Physiks::Sphere::Sphere(const Sphere &sph) : RigidBody(sph), radius(sph.radius) {}

Physiks::Sphere::Sphere(PHYSCALAR m, PHYSCALAR c, const Vector &pos, const Vector &vel,
    const Vector &ang_vel, PHYSCALAR rad) : 
  RigidBody(0.0, 0.0, position, velocity, ang_vel), radius(rad) {}

Physiks::Sphere::~Sphere() {}



// Definitions for Physiks::Plane /////////////////////////////////////////

Physiks::Plane::Plane(const Vector &normal, const Vector &origin) :
  RigidBody(), unbounded(true), normal_vec(Vector::normalize(normal)) {
    position.set(origin);
}

Physiks::Plane::Plane(const Vector &vec1, const Vector &vec2, const Vector &origin) : 
  RigidBody(), unbounded(false), normal_vec(Vector::normalize(Vector::cross(vec1, vec2))),
  basis_vec1(vec1), basis_vec2(vec2) {
    position.set(origin);
}

Physiks::Plane::~Plane() {}

void Physiks::Plane::bounded(bool flag) {
  unbounded = !flag;
}

bool Physiks::Plane::bounded() const {
  return !unbounded;
}

Vector Physiks::Plane::normal() const {
  return normal_vec;
}
