// system includes
#include <math.h>
#include <iostream.h>
#include <stdlib.h>

// openGL includes
#include <GL/gl.h>
#include <GL/glu.h>

// gprims utility library: need definition of max_flt, etc.
#include "gprims/vector.H"

// local includes
#include "drawutils.H"
#include "optfxn.H"
#include "object.H"

Optfxn::Optfxn( Float3 *eqn ) {
  _eqn = new Float3(0.0,0.0,0.0);
  _sphere = new Sphere();
  setEqn(eqn);
}

int
Optfxn::setEqn( Float3 *eqn) {
  (*_eqn) = (*eqn);
  _sphere->setPosition(_eqn);
  return 1;
}

int
Optfxn::draw(float r, float g, float b, BB *bb) {
  if (bb->insidePoint(_eqn)) {
    glBegin(GL_LINES);
    glColor3f(r,g,b);
    glVertex3f(0.0,0.0,0.0);
    glVertex3f(eqn.x, eqn.y, eqn.z);
    glEnd();
    _sphere->draw();
    return 1;
  }
  return 0;
}
