📄 common.h
字号:
#ifndef _COMMON_H#define _COMMON_H#include <stdlib.h>#include <gl/glut.h>// C output#include <stdio.h>// Math functions#include <math.h>#define min(X, Y) X<Y?X:Y// Should be in Math.h but Visual C++ omits it ... for some reason ...#define M_PI 3.1415926// C++ Output#include <iostream>using namespace std;// Ansi Assertions#include <assert.h>//@@@@@@@@@@@@@@@@@@ IntPoint class @@@@@@@@@@@@@@@@class IntPoint{ // for 2D points with integer coordinatespublic: int x,y; void set(int dx, int dy); void set(IntPoint& p); IntPoint(int xx, int yy); IntPoint();};class Point2 //single point w/ floating point coordinates{public: Point2(); Point2(float xx, float yy); void set(float xx, float yy); float getX(); float getY(); void draw();private: float x, y;};//@@@@@@@@@@@@@@@@@@ Point3 class @@@@@@@@@@@@@@@@class Point3{public: float x,y,z,h; Point3(float xx, float yy, float zz); Point3(); void set(float dx, float dy, float dz); void set(Point3& p); void build4tuple(float v[]);};class IntRect //aligned rectangle with integer coordinates, used for viewport{public: IntRect(); IntRect(int left, int right, int bottom, int top); void set(int left, int right, int bottom, int top); void draw(); int getL(); int getR(); int getT(); int getB();public: int l, r, b, t;};class RealRect //simlar to IntRect but w/ floating points & used for world window{public: RealRect(); RealRect(float left, float right, float bottom, float top); void set(float left, float right, float bottom, float top); void draw(void); float getL(void); float getR(void); float getT(void); float getB(void);private: float l, r, b, t;};// @@@@@@@@@@@@@@@@@@@@@ Color3 class @@@@@@@@@@@@@@@@class Color3{public: float red, green, blue; Color3();// Color3(Color3& c); Color3(float r, float g, float b); void make(Color3 c); void set(Color3& c); void set(float r, float g, float b); void scale(float l); void build4tuple(float v[]);// void clamp(); //<-- Removed in favor of tone mapping bool isZero(); void add(float r, float g, float b); void add(Color3& src, Color3& refl); void add(Color3& colr);};//@@@@@@@@@@@@@@@@@@ Vector3 class @@@@@@@@@@@@@@@@class Vector3{public: float x,y,z; Vector3(float xx, float yy, float zz);// Vector3(Vector3& v); Vector3(); void set(float dx, float dy, float dz); void set(Vector3 v); void setDiff(Point3& a, Point3& b); void flip(); void normalize(); double length(); Vector3 cross(Vector3 b); float dot(Vector3 b); void add(Vector3 a); void scale(float a); void rotate(float angle, Vector3 axis); void build4tuple(float v[]);};//@@@@@@@@@@@@@@@@@@@ PointCluster class @@@@@@@@@@@@@@@@@@class PointCluster{public: // holds array of points for the bounding hull of a shape int num; Point3* pt; PointCluster(); PointCluster(int n);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -