Triton
Visual simulation library for ocean rendering.
Vector4.h
Go to the documentation of this file.
1// Copyright (c) 2004-2012 Sundog Software, LLC. All rights reserved worldwide.
2
8#ifdef SWIG
9%module TritonVector4
10#define TRITONAPI
11%{
12#include "Vector4.h"
13using namespace Triton;
14%}
15#endif
16
17#ifndef TRITON_VECTOR4_H
18#define TRITON_VECTOR4_H
19
20#include "MemAlloc.h"
21#include "Vector3.h"
22
23#pragma pack(push)
24#pragma pack(8)
25
26namespace Triton
27{
30class Vector4 : public MemObject
31{
32public:
34 Vector4(double px, double py, double pz, double pw) : x(px), y(py), z(pz), w(pw) {
35 }
36
38 Vector4(const Vector3& v3) : x(v3.x), y(v3.y), z(v3.z), w(1.0) {
39 }
40
42 Vector4() : x(0), y(0), z(0), w(1.0) {
43 }
44
47 double TRITONAPI Dot (const Vector4& v) const {
48 return x * v.x + y * v.y + z * v.z + w * v.w;
49 }
50
52 Vector4 TRITONAPI operator * (double n) const {
53 return Vector4(x*n, y*n, z*n, w*n);
54 }
55
57 Vector4 TRITONAPI operator * (const Vector4& v) const {
58 return Vector4(x*v.x, y*v.y, z*v.z, w*v.w);
59 }
60
62 Vector4 TRITONAPI operator + (double n) const {
63 return Vector4(x+n, y+n, z+n, w+n);
64 }
65
67 Vector4 TRITONAPI operator - (const Vector4& v) const {
68 return Vector4(x - v.x, y - v.y, z - v.z, w - v.w);
69 }
70
72 Vector4 TRITONAPI operator + (const Vector4& v) const {
73 return Vector4(x + v.x, y + v.y, z + v.z, w + v.w);
74 }
76 double x, y, z, w;
77};
78}
79
80#pragma pack(pop)
81
82#endif
Memory allocation interface for SilverLining.
A 3D Vector class and its operations.
A simple 4D vector class.
This base class for all Triton objects intercepts the new and delete operators, routing them through ...
Definition: MemAlloc.h:71
A 3D double-precision Vector class and its operations.
Definition: Vector3.h:36
A simple double-precision 4D vector class with no operations defined.
Definition: Vector4.h:31
Vector4 TRITONAPI operator*(double n) const
Scales each x,y,z value of the vector by a constant n, and returns the result.
Definition: Vector4.h:52
Vector4 TRITONAPI operator+(double n) const
Adds a constant n to each component of the vector, and returns the result.
Definition: Vector4.h:62
Vector4(double px, double py, double pz, double pw)
Constructs a Vector4 from the given x, y, z, and w values.
Definition: Vector4.h:34
Vector4(const Vector3 &v3)
Constructs a Vector4 from a Vector3, setting w to 1.
Definition: Vector4.h:38
double TRITONAPI Dot(const Vector4 &v) const
Determines the dot product between this vector and another, and returns the result.
Definition: Vector4.h:47
Vector4()
Default constructor; initializes the Vector4 to (0, 0, 0, 1)
Definition: Vector4.h:42
Vector4 TRITONAPI operator-(const Vector4 &v) const
Subtracts the specified vector from this vector, and returns the result.
Definition: Vector4.h:67
double x
The x, y, z, and w data members are public for convenience.
Definition: Vector4.h:76