28 #ifndef GRAPHICS_TINYGL_ZMATH_H 29 #define GRAPHICS_TINYGL_ZMATH_H 42 Vector3(
float x,
float y,
float z) {
50 float getLength()
const {
return sqrt(X * X + Y * Y + Z * Z); }
52 bool operator==(
const Vector3 &other)
const {
53 return X == other.X && Y == other.Y && Z == other.Z;
56 bool operator!=(
const Vector3 &other)
const {
57 return X != other.X || Y != other.Y || Z != other.Z;
64 Vector3 operator*(
float factor)
const {
65 return Vector3(X * factor, Y * factor, Z * factor);
69 return Vector3(X + other.X, Y + other.Y, Z + other.Z);
73 return Vector3(X - other.X, Y - other.Y, Z - other.Z);
76 Vector3 &operator*=(
float factor) {
83 Vector3 &operator+=(
float value) {
90 Vector3 &operator-=(
float value) {
105 Vector4(
float x,
float y,
float z,
float w) {
112 bool operator==(
const Vector4 &other)
const {
113 return X == other.X && Y == other.Y && Z == other.Z && W == other.W;
116 bool operator!=(
const Vector4 &other)
const {
117 return X != other.X || Y != other.Y || Z != other.Z || W != other.W;
121 return Vector4(-X, -Y, -Z, -W);
124 Vector4 operator*(
float factor)
const {
125 return Vector4(X * factor, Y * factor, Z * factor,W * factor);
129 return Vector4(X + other.X, Y + other.Y, Z + other.Z, W + other.W);
133 return Vector4(X - other.X, Y - other.Y, Z - other.Z, W - other.W);
136 Vector4 &operator*=(
float factor) {
144 Vector4 &operator+=(
float value) {
152 Vector4 &operator-=(
float value) {
167 bool isIdentity()
const;
171 for (
int i = 0; i < 4; i++) {
172 for (
int j = 0; j < 4; j++) {
173 result._m[i][j] = _m[i][j] + b._m[i][j];
181 for (
int i = 0; i < 4; i++) {
182 for (
int j = 0; j < 4; j++) {
183 result._m[i][j] = _m[i][j] - b._m[i][j];
191 for (
int i = 0; i < 4; i++) {
192 for (
int j = 0; j < 4; j++) {
194 for (
int k = 0; k < 4; k++)
195 s += _m[i][k] * b._m[k][j];
205 for (
int i = 0; i < 4; i++) {
206 for (
int j = 0; j < 4; j++) {
208 for (
int k = 0; k < 4; k++)
209 s += a._m[i][k] * b._m[k][j];
216 void scale(
float x,
float y,
float z);
217 void translate(
float x,
float y,
float z);
219 void rotation(
float t,
int);
228 static Matrix4 frustum(
float left,
float right,
float bottom,
float top,
float nearp,
float farp);
230 inline void transform(
const Vector3 &vector,
Vector3 &out)
const {
231 out.X = vector.X * _m[0][0] + vector.Y * _m[0][1] + vector.Z * _m[0][2] + _m[0][3];
232 out.Y = vector.X * _m[1][0] + vector.Y * _m[1][1] + vector.Z * _m[1][2] + _m[1][3];
233 out.Z = vector.X * _m[2][0] + vector.Y * _m[2][1] + vector.Z * _m[2][2] + _m[2][3];
237 inline void transform3x3(
const Vector3 &vector,
Vector3 &out)
const {
238 out.X = vector.X * _m[0][0] + vector.Y * _m[0][1] + vector.Z * _m[0][2];
239 out.Y = vector.X * _m[1][0] + vector.Y * _m[1][1] + vector.Z * _m[1][2];
240 out.Z = vector.X * _m[2][0] + vector.Y * _m[2][1] + vector.Z * _m[2][2];
244 inline void transform3x3(
const Vector4 &vector,
Vector3 &out)
const {
245 out.X = vector.X * _m[0][0] + vector.Y * _m[0][1] + vector.Z * _m[0][2];
246 out.Y = vector.X * _m[1][0] + vector.Y * _m[1][1] + vector.Z * _m[1][2];
247 out.Z = vector.X * _m[2][0] + vector.Y * _m[2][1] + vector.Z * _m[2][2];
251 inline void transform3x4(
const Vector4 &vector,
Vector4 &out)
const {
252 out.X = vector.X * _m[0][0] + vector.Y * _m[0][1] + vector.Z * _m[0][2] + _m[0][3];
253 out.Y = vector.X * _m[1][0] + vector.Y * _m[1][1] + vector.Z * _m[1][2] + _m[1][3];
254 out.Z = vector.X * _m[2][0] + vector.Y * _m[2][1] + vector.Z * _m[2][2] + _m[2][3];
255 out.W = vector.X * _m[3][0] + vector.Y * _m[3][1] + vector.Z * _m[3][2] + _m[3][3];
258 inline void transform(
const Vector4 &vector,
Vector4 &out)
const {
259 out.X = vector.X * _m[0][0] + vector.Y * _m[0][1] + vector.Z * _m[0][2] + vector.W * _m[0][3];
260 out.Y = vector.X * _m[1][0] + vector.Y * _m[1][1] + vector.Z * _m[1][2] + vector.W * _m[1][3];
261 out.Z = vector.X * _m[2][0] + vector.Y * _m[2][1] + vector.Z * _m[2][2] + vector.W * _m[2][3];
262 out.W = vector.X * _m[3][0] + vector.Y * _m[3][1] + vector.Z * _m[3][2] + vector.W * _m[3][3];
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: colormasks.h:27