8dfa3d737e8d19b922e748ec32d8005f5902e927
8 Vec3f::Vec3f(float x
, float y
, float z
) {
17 Vec3f::Vec3f(const Vec3f
& o
) {
18 for (size_t i
= 0; i
< DIM
; i
++) {
19 m_values
[i
] = o
.m_values
[i
];
23 Vec3f
& Vec3f::operator=(const Vec3f
& o
) {
24 for (size_t i
= 0; i
< DIM
; i
++) {
25 m_values
[i
] = o
.m_values
[i
];
30 float Vec3f::operator|(const Vec3f
& o
) {
35 float Vec3f::dot(const Vec3f
& o
) {
37 for (size_t i
= 0; i
< DIM
; i
++) {
38 prod
+= m_values
[i
] * o
.m_values
[i
];
43 Vec3f
Vec3f::operator%(const Vec3f
& o
) {
47 Vec3f
Vec3f::cross(const Vec3f
& o
) {
48 return Vec3f(m_values
[1] * o
.m_values
[2] - m_values
[2] * o
.m_values
[1],
49 m_values
[2] * o
.m_values
[0] - m_values
[0] * o
.m_values
[2], m_values
[0]
50 * o
.m_values
[1] - m_values
[1] * o
.m_values
[0]);
53 void Vec3f::normalize() {
57 float Vec3f::norm() const {
58 return sqrt(m_values
[0] * m_values
[0] + m_values
[1] * m_values
[1]
59 + m_values
[2] * m_values
[2]);
62 Vec3f
Vec3f::operator*(const float t
) const {
67 Vec3f
& Vec3f::operator*=(const float t
) {
68 for (unsigned int i
= 0; i
< 3; ++i
) {
74 Vec3f
Vec3f::operator/(const float t
) const {
79 Vec3f
& Vec3f::operator/=(const float t
) {
80 for (unsigned int i
= 0; i
< 3; ++i
) {
86 // example implementation of a standard operator
87 Vec3f
Vec3f::operator+(const Vec3f
& o
) const {
92 // example implementation of an in-place operator
93 Vec3f
& Vec3f::operator+=(const Vec3f
& o
) {
94 for (unsigned int i
= 0; i
< 3; ++i
) {
95 m_values
[i
] += o
.m_values
[i
];
100 Vec3f
Vec3f::operator-(const Vec3f
& o
) const {
105 Vec3f
& Vec3f::operator-=(const Vec3f
& o
) {
106 for (unsigned int i
= 0; i
< 3; ++i
) {
107 m_values
[i
] -= o
.m_values
[i
];
112 Vec3f
Vec3f::operator*(const Vec3f
& o
) const {
117 Vec3f
& Vec3f::operator*=(const Vec3f
& o
) {
118 for (unsigned int i
= 0; i
< 3; ++i
) {
119 m_values
[i
] *= o
.m_values
[i
];
124 Vec3f
Vec3f::operator/(const Vec3f
& o
) const {
129 Vec3f
& Vec3f::operator/=(const Vec3f
& o
) {
130 for (unsigned int i
= 0; i
< 3; ++i
) {
131 m_values
[i
] /= o
.m_values
[i
];
136 float Vec3f::operator[](unsigned int i
) const {
141 float& Vec3f::operator[](unsigned int i
) {
This page took 0.050228 seconds and 3 git commands to generate.