  | 
  
    CUGL 1.3
    
   Cornell University Game Library 
   | 
 
 
 
 
   41 #include "CUMathBase.h" 
   85 #pragma mark Constructors 
   99     Vec3(
float x, 
float y, 
float z) { this->x = 
x; this->y = 
y; this->z = 
z; }
 
  106     Vec3(
const float* array) { 
x = array[0]; 
y = array[1]; 
z = array[2]; }
 
  115         x = p2.
x-p1.
x; 
y = p2.
y-p1.
y; 
z = p2.
z-p1.
z;
 
  142         this->x = 
x; this->y = 
y; this->z = 
z;
 
  154         x = array[0]; 
y = array[1]; 
z = array[2];
 
  166         x = v.
x; 
y = v.
y; 
z = v.
z;
 
  179         x = p2.
x-p1.
x; 
y = p2.
y-p1.
y; 
z = p2.
z-p1.
z;
 
  195 #pragma mark Static Arithmetic 
  323 #pragma mark Arithmetic 
  333         x = clampf(
x, min.
x, max.
x);
 
  334         y = clampf(
y, min.
y, max.
y);
 
  335         z = clampf(
z, min.
z, max.
z);
 
  350         return Vec3(clampf(
x,min.
x,max.
x), clampf(
y, min.
y, max.
y),clampf(
z, min.
z, max.
z));
 
  361         x += v.
x; 
y += v.
y; 
z += v.
z;
 
  375         this->x += 
x; this->y += 
y; this->z += 
z;
 
  387         x -= v.
x; 
y -= v.
y; 
z -= v.
z;
 
  401         this->x -= 
x; this->y -= 
y; this->z -= 
z;
 
  413         x *= s; 
y *= s; 
z *= s;
 
  427         x *= sx; 
y *= sy; 
z *= sz;
 
  439         x *= v.
x; 
y *= v.
y; 
z *= v.
z;
 
  494         x = 1.0f/
x; 
y = 1.0f/
y; 
z = 1.0f/
z;
 
  537         x = func(
x); 
y = func(
y); 
z = func(
z);
 
  552         return Vec3(func(
x), func(
y), func(
z));
 
  557 #pragma mark Operators 
  637         return result.
add(v);
 
  677         return result.
scale(s);
 
  692         return result.
scale(v);
 
  726 #pragma mark Comparisons 
  739         return (
x == v.
x ? (
y == v.
y ? 
z < v.
z : 
y < v.
y) : 
x < v.
x);
 
  754         return (
x == v.
x ? (
y == v.
y ? 
z <= v.
z : 
y <= v.
y) : 
x <= v.
x);
 
  769         return (
x == v.
x ? (
y == v.
y ? 
z > v.
z : 
y > v.
y) : 
x > v.
x);
 
  784         return (
x == v.
x ? (
y == v.
y ? 
z >= v.
z : 
y >= v.
y) : 
x >= v.
x);
 
  798         return x == v.
x && 
y == v.
y && 
z == v.
z;
 
  812         return x != v.
x || 
y != v.
y || 
z != v.
z;
 
  826         return x <= v.
x && 
y <= v.
y && 
z <= v.
z;
 
  840         return x >= v.
x && 
y >= v.
y && 
z >= v.
z;
 
  854     bool equals(
const Vec3& v, 
float variance=CU_MATH_EPSILON)
 const {
 
  860 #pragma mark Linear Attributes 
  867         return x == 0.0f && 
y == 0.0f && 
z == 0.0f;
 
  887         return x == 1.0f && 
y == 1.0f && 
z == 1.0f;
 
  896         return x != 0.0f && 
y != 0.0f && 
z != 0.0f;
 
  906     bool isUnit(
float variance=CU_MATH_EPSILON)
 const {
 
  908         return dot < variance && dot > -variance;
 
  985 #pragma mark Linear Algebra 
 1003         return *(
cross(*
this,v,
this));
 
 1017         return result.
cross(other);
 
 1058         return Vec3((
x + other.
x) / 2.0f, (
y + other.
y) / 2.0f, (
z + other.
z) / 2.0f);
 
 1083         return other * (
dot(other)/other.
dot(other));
 
 1099         *
this *= (1.f - alpha);
 
 1100         return *
this += other * alpha;
 
 1116         return *
this * (1.f - alpha) + other * alpha;
 
 1137 #pragma mark Static Linear Algebra 
 1212 #pragma mark Conversion Methods 
 1224     std::string 
toString(
bool verbose = 
false) 
const;
 
 1280     operator Vec2() 
const;
 
 1308     operator Vec4() 
const;
 
 1335 #pragma mark Friend Operations 
 1345 inline const Vec3 operator*(
float x, 
const Vec3& v) {
 
 1347     return result.scale(x);
 
 1351 typedef Vec3 Point3;
 
  
Vec3 getProjection(const Vec3 &other) const
Definition: CUVec3.h:1082
 
Vec3 & set(float x, float y, float z)
Definition: CUVec3.h:141
 
bool isInvertible() const
Definition: CUVec3.h:895
 
Vec3 & subtract(float x, float y, float z)
Definition: CUVec3.h:400
 
Vec3 & subtract(const Vec3 &v)
Definition: CUVec3.h:386
 
Vec3 & operator/=(const Vec3 &v)
Definition: CUVec3.h:622
 
Vec3 & scale(float sx, float sy, float sz)
Definition: CUVec3.h:426
 
float x
Definition: CUVec3.h:66
 
float z
Definition: CUVec3.h:70
 
static Vec3 * clamp(const Vec3 &v, const Vec3 &min, const Vec3 &max, Vec3 *dst)
 
float distance(const Vec3 &v) const
Definition: CUVec3.h:934
 
Vec3 getNormalization() const
Definition: CUVec3.h:1043
 
Vec3 & add(const Vec3 &v)
Definition: CUVec3.h:360
 
Vec3 getCross(const Vec3 &other) const
Definition: CUVec3.h:1015
 
bool isNearZero(float variance=CU_MATH_EPSILON) const
Definition: CUVec3.h:877
 
Vec3 & scale(const Vec3 &v)
Definition: CUVec3.h:438
 
Vec3()
Definition: CUVec3.h:90
 
Vec3 & operator+=(const Vec3 &v)
Definition: CUVec3.h:565
 
static Vec3 * negate(const Vec3 &v, Vec3 *dst)
 
static Vec3 * scale(const Vec3 &v, float s, Vec3 *dst)
 
Vec3 & operator/=(float s)
Definition: CUVec3.h:609
 
static const Vec3 UNIT_X
Definition: CUVec3.h:77
 
Vec3 & operator*=(float s)
Definition: CUVec3.h:587
 
Vec3 getMap(std::function< float(float)> func) const
Definition: CUVec3.h:551
 
bool operator>(const Vec3 &v) const
Definition: CUVec3.h:768
 
Vec3 & scale(float s)
Definition: CUVec3.h:412
 
Definition: CUColor4.h:1084
 
Vec3(const float *array)
Definition: CUVec3.h:106
 
Vec3 getLerp(const Vec3 &other, float alpha)
Definition: CUVec3.h:1115
 
static Vec3 * reciprocate(const Vec3 &v, Vec3 *dst)
 
Vec3(const Vec3 &p1, const Vec3 &p2)
Definition: CUVec3.h:114
 
bool operator<=(const Vec3 &v) const
Definition: CUVec3.h:753
 
Vec3 & add(float x, float y, float z)
Definition: CUVec3.h:374
 
bool equals(const Vec3 &v, float variance=CU_MATH_EPSILON) const
Definition: CUVec3.h:854
 
Vec3 getMidpoint(const Vec3 &other) const
Definition: CUVec3.h:1057
 
float lengthSquared() const
Definition: CUVec3.h:979
 
bool operator!=(const Vec3 &v) const
Definition: CUVec3.h:811
 
Vec3 & map(std::function< float(float)> func)
Definition: CUVec3.h:536
 
Vec3 getNegation() const
Definition: CUVec3.h:505
 
bool isZero() const
Definition: CUVec3.h:866
 
const Vec3 operator/(const Vec3 &v) const
Definition: CUVec3.h:719
 
Vec3 & set(const float *array)
Definition: CUVec3.h:153
 
static float angle(const Vec3 &v1, const Vec3 &v2, const Vec3 &up=Vec3::UNIT_Z)
 
static const Vec3 ZERO
Definition: CUVec3.h:73
 
Vec3 & lerp(const Vec3 &other, float alpha)
Definition: CUVec3.h:1098
 
const Vec3 operator-(const Vec3 &v) const
Definition: CUVec3.h:649
 
Vec3 & reciprocate()
Definition: CUVec3.h:493
 
Vec3 & set(const Vec3 &v)
Definition: CUVec3.h:165
 
static const Vec3 UNIT_Y
Definition: CUVec3.h:79
 
const Vec3 operator/(float s) const
Definition: CUVec3.h:704
 
const Vec3 operator+(const Vec3 &v) const
Definition: CUVec3.h:635
 
float getAngle(const Vec3 &other, const Vec3 &up=Vec3::UNIT_Z) const
 
bool operator<(const Vec3 &v) const
Definition: CUVec3.h:738
 
Vec3 & operator-=(const Vec3 &v)
Definition: CUVec3.h:576
 
Definition: CUColor4.h:73
 
Vec3 & operator*=(const Vec3 &v)
Definition: CUVec3.h:598
 
const Vec3 operator*(const Vec3 &v) const
Definition: CUVec3.h:690
 
static Vec3 * add(const Vec3 &v1, const Vec3 &v2, Vec3 *dst)
 
float y
Definition: CUVec3.h:68
 
Vec3 getReciprocal() const
Definition: CUVec3.h:521
 
std::string toString(bool verbose=false) const
 
Vec3 & set(const Vec3 &p1, const Vec3 &p2)
Definition: CUVec3.h:178
 
Vec3 & setZero()
Definition: CUVec3.h:188
 
static Vec3 * subtract(const Vec3 &v1, const Vec3 &v2, Vec3 *dst)
 
static const Vec3 ONE
Definition: CUVec3.h:75
 
bool isOne() const
Definition: CUVec3.h:886
 
float length() const
Definition: CUVec3.h:963
 
Vec3 & negate()
Definition: CUVec3.h:479
 
const Vec3 operator-() const
Definition: CUVec3.h:661
 
float distanceSquared(const Vec3 &v) const
Definition: CUVec3.h:952
 
static Vec3 * midpoint(const Vec3 &v1, const Vec3 &v2, Vec3 *dst)
 
static const Vec3 UNIT_Z
Definition: CUVec3.h:81
 
bool isUnit(float variance=CU_MATH_EPSILON) const
Definition: CUVec3.h:906
 
static Vec3 * divide(const Vec3 &v, float s, Vec3 *dst)
 
Vec3 & operator=(const float *array)
Definition: CUVec3.h:128
 
Vec3 & smooth(const Vec3 &target, float elapsed, float response)
 
Vec3 & cross(const Vec3 &v)
Definition: CUVec3.h:1002
 
Vec3 getClamp(const Vec3 &min, const Vec3 &max) const
Definition: CUVec3.h:349
 
Vec3 & clamp(const Vec3 &min, const Vec3 &max)
Definition: CUVec3.h:332
 
bool operator>=(const Vec3 &v) const
Definition: CUVec3.h:783
 
Vec3 & project(const Vec3 &other)
Definition: CUVec3.h:1068
 
Vec3(float x, float y, float z)
Definition: CUVec3.h:99
 
const Vec3 operator*(float s) const
Definition: CUVec3.h:675
 
bool under(const Vec3 &v) const
Definition: CUVec3.h:825
 
bool over(const Vec3 &v) const
Definition: CUVec3.h:839
 
float dot(const Vec3 &v) const
Definition: CUVec3.h:993
 
bool operator==(const Vec3 &v) const
Definition: CUVec3.h:797