deleted /gvsu/cs658/final directory
git-svn-id: svn://anubis/gvsu@373 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
038c923fed
commit
03226f0518
@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
ifdef WIN32
|
|
||||||
export CPPFLAGS += -I"$(shell cd)"
|
|
||||||
else
|
|
||||||
export CPPFLAGS += -I"$(shell pwd)"
|
|
||||||
endif
|
|
||||||
|
|
||||||
all:
|
|
||||||
make -C util
|
|
||||||
make -C shapes
|
|
||||||
make -C test
|
|
||||||
|
|
||||||
clean:
|
|
||||||
make -C test clean
|
|
||||||
make -C shapes clean
|
|
||||||
make -C util clean
|
|
@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc))
|
|
||||||
|
|
||||||
all: $(OBJS)
|
|
||||||
|
|
||||||
%.o: %.cc
|
|
||||||
$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<
|
|
||||||
|
|
||||||
# Make dependency files
|
|
||||||
%.dep: %.cc
|
|
||||||
@set -e; rm -f $@; \
|
|
||||||
$(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \
|
|
||||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
|
||||||
rm -f $@.$$$$
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-$(RM) -f *.o *.dep $(ARCHIVE)
|
|
||||||
|
|
||||||
# Include dependency files
|
|
||||||
include $(OBJS:.o=.dep)
|
|
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
#ifndef SHAPE_H
|
|
||||||
#define SHAPE_H SHAPE_H
|
|
||||||
|
|
||||||
#include "util/Solver.h"
|
|
||||||
#include "util/Ray.h"
|
|
||||||
|
|
||||||
class Shape
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual Solver::Result intersect(const Ray & ray) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
#include "Sphere.h"
|
|
||||||
#include "util/Solver.h"
|
|
||||||
|
|
||||||
Sphere::Sphere(double radius)
|
|
||||||
{
|
|
||||||
m_radius = radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
Solver::Result Sphere::intersect(const Ray & ray)
|
|
||||||
{
|
|
||||||
Solver::Result res;
|
|
||||||
QuadraticSolver solver(1.0,
|
|
||||||
2 * ( ray.getOrigin()[0] * ray.getDirection()[0]
|
|
||||||
+ ray.getOrigin()[1] * ray.getDirection()[1]
|
|
||||||
+ ray.getOrigin()[2] * ray.getDirection()[2] ),
|
|
||||||
ray.getOrigin()[0] * ray.getOrigin()[0]
|
|
||||||
+ ray.getOrigin()[1] * ray.getOrigin()[1]
|
|
||||||
+ ray.getOrigin()[2] * ray.getOrigin()[2] );
|
|
||||||
Solver::Result quadSolutions = solver.solve();
|
|
||||||
return res;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
#ifndef SPHERE_H
|
|
||||||
#define SPHERE_H SPHERE_H
|
|
||||||
|
|
||||||
#include "Shape.h"
|
|
||||||
|
|
||||||
class Sphere : public Shape
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Sphere(double radius);
|
|
||||||
Solver::Result intersect(const Ray & ray);
|
|
||||||
|
|
||||||
private:
|
|
||||||
double m_radius;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
all:
|
|
||||||
@echo Nothing yet.
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@echo Nothing yet.
|
|
@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc))
|
|
||||||
|
|
||||||
all: $(OBJS)
|
|
||||||
|
|
||||||
%.o: %.cc
|
|
||||||
$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<
|
|
||||||
|
|
||||||
# Make dependency files
|
|
||||||
%.dep: %.cc
|
|
||||||
@set -e; rm -f $@; \
|
|
||||||
$(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \
|
|
||||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
|
||||||
rm -f $@.$$$$
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-$(RM) -f *.o *.dep $(ARCHIVE)
|
|
||||||
|
|
||||||
# Include dependency files
|
|
||||||
include $(OBJS:.o=.dep)
|
|
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
#include "Ray.h"
|
|
||||||
|
|
||||||
Ray::Ray()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Ray::Ray(const Vector & origin, const Vector & direction)
|
|
||||||
{
|
|
||||||
m_origin = origin;
|
|
||||||
m_direction = direction;
|
|
||||||
m_direction.normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* return a vector for the point at distance dist
|
|
||||||
* from the ray's origin point, along its direction.
|
|
||||||
*/
|
|
||||||
Vector Ray::getPositionAt(double dist) const
|
|
||||||
{
|
|
||||||
Vector v;
|
|
||||||
v[0] = m_origin[0] + dist * m_direction[0];
|
|
||||||
v[1] = m_origin[1] + dist * m_direction[1];
|
|
||||||
v[2] = m_origin[2] + dist * m_direction[2];
|
|
||||||
return v;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
#ifndef RAY_H
|
|
||||||
#define RAY_H RAY_H
|
|
||||||
|
|
||||||
#include "Vector.h"
|
|
||||||
|
|
||||||
class Ray
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Ray();
|
|
||||||
Ray(const Vector & origin, const Vector & direction);
|
|
||||||
const Vector & getOrigin() const { return m_origin; }
|
|
||||||
const Vector & getDirection() const { return m_direction; }
|
|
||||||
Vector getPositionAt(double dist) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Vector m_origin;
|
|
||||||
Vector m_direction;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
|||||||
|
|
||||||
#include "Solver.h"
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
/* Generic Solver constructor */
|
|
||||||
Solver::Solver(double a, double b, double c, double d, double e)
|
|
||||||
{
|
|
||||||
this->a = a;
|
|
||||||
this->b = b;
|
|
||||||
this->c = c;
|
|
||||||
this->d = d;
|
|
||||||
this->e = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* QuadraticSolver methods *
|
|
||||||
*************************************************************************/
|
|
||||||
QuadraticSolver::QuadraticSolver(double a, double b, double c)
|
|
||||||
: Solver(a, b, c)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* solve a quadratic equation */
|
|
||||||
Solver::Result QuadraticSolver::solve()
|
|
||||||
{
|
|
||||||
Result res;
|
|
||||||
double discriminant = b * b - 4 * a * c;
|
|
||||||
if (discriminant < 0.0)
|
|
||||||
{
|
|
||||||
res.numResults = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
double sqrt_discriminant = sqrt(discriminant);
|
|
||||||
double two_a = 2.0 * a;
|
|
||||||
if (sqrt_discriminant = 0.0)
|
|
||||||
{
|
|
||||||
res.numResults = 1;
|
|
||||||
res.results[0] = (-b) / two_a;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res.numResults = 2;
|
|
||||||
res.results[0] = (-b - sqrt_discriminant) / two_a;
|
|
||||||
res.results[1] = (-b + sqrt_discriminant) / two_a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* CubicSolver methods *
|
|
||||||
*************************************************************************/
|
|
||||||
CubicSolver::CubicSolver(double a, double b, double c, double d)
|
|
||||||
: Solver(a, b, c, d)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Solver::Result CubicSolver::solve()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* QuarticSolver methods *
|
|
||||||
*************************************************************************/
|
|
||||||
QuarticSolver::QuarticSolver(double a, double b, double c, double d, double e)
|
|
||||||
: Solver(a, b, c, d, e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Solver::Result QuarticSolver::solve()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
|
|
||||||
#ifndef SOLVER_H
|
|
||||||
#define SOLVER_H SOLVER_H
|
|
||||||
|
|
||||||
class Solver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int numResults;
|
|
||||||
double results[4];
|
|
||||||
} Result;
|
|
||||||
|
|
||||||
Solver(double a = 0.0,
|
|
||||||
double b = 0.0,
|
|
||||||
double c = 0.0,
|
|
||||||
double d = 0.0,
|
|
||||||
double e = 0.0);
|
|
||||||
virtual Result solve() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
double a, b, c, d, e;
|
|
||||||
};
|
|
||||||
|
|
||||||
class QuadraticSolver : public Solver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QuadraticSolver(double a, double b, double c);
|
|
||||||
Result solve();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CubicSolver : public Solver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CubicSolver(double a, double b, double c, double d);
|
|
||||||
Result solve();
|
|
||||||
};
|
|
||||||
|
|
||||||
class QuarticSolver : public Solver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QuarticSolver(double a, double b, double c, double d, double e);
|
|
||||||
Result solve();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
|
|
||||||
#include "Vector.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
Vector::Vector()
|
|
||||||
{
|
|
||||||
m_array[0] = 0.0;
|
|
||||||
m_array[1] = 0.0;
|
|
||||||
m_array[2] = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Vector::normalize()
|
|
||||||
{
|
|
||||||
double length = sqrt(m_array[0] * m_array[0]
|
|
||||||
+ m_array[1] * m_array[1]
|
|
||||||
+ m_array[2] * m_array[2]);
|
|
||||||
m_array[0] /= length;
|
|
||||||
m_array[1] /= length;
|
|
||||||
m_array[2] /= length;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & out, const Vector & v)
|
|
||||||
{
|
|
||||||
out << "[" << v[0] << ", " << v[1] << ", " << v[2] << "]";
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compute the dot-product of two vectors */
|
|
||||||
double operator%(const Vector & v1, const Vector & v2)
|
|
||||||
{
|
|
||||||
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compute the cross-product of two vectors */
|
|
||||||
Vector operator*(const Vector & v1, const Vector & v2)
|
|
||||||
{
|
|
||||||
Vector result;
|
|
||||||
result[0] = v1[1] * v2[2] - v1[2] * v2[1];
|
|
||||||
result[1] = v1[2] * v2[0] - v1[0] * v2[2];
|
|
||||||
result[2] = v1[0] * v2[1] - v1[1] * v2[0];
|
|
||||||
return result;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
#ifndef VECTOR_H
|
|
||||||
#define VECTOR_H VECTOR_H
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
class Vector
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Vector();
|
|
||||||
~Vector();
|
|
||||||
double & operator[](int idx) { return m_array[idx]; }
|
|
||||||
double operator[](int idx) const { return m_array[idx]; }
|
|
||||||
void normalize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
double m_array[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & out, const Vector & v);
|
|
||||||
double operator%(const Vector & v1, const Vector & v2);
|
|
||||||
Vector operator*(const Vector & v1, const Vector & v2);
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
x
Reference in New Issue
Block a user