equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * quaternion.h: Quaternion class |
2 * quaternion.h: Quaternion class |
3 * |
3 * |
4 * This file is part of Pyrit Ray Tracer. |
4 * This file is part of Pyrit Ray Tracer. |
5 * |
5 * |
6 * Copyright 2007 Radek Brich |
6 * Copyright 2007, 2008 Radek Brich |
7 * |
7 * |
8 * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 * Permission is hereby granted, free of charge, to any person obtaining a copy |
9 * of this software and associated documentation files (the "Software"), to deal |
9 * of this software and associated documentation files (the "Software"), to deal |
10 * in the Software without restriction, including without limitation the rights |
10 * in the Software without restriction, including without limitation the rights |
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
42 }; |
42 }; |
43 }; |
43 }; |
44 Quaternion(): a(0), b(0), c(0), d(0) {}; |
44 Quaternion(): a(0), b(0), c(0), d(0) {}; |
45 Quaternion(const Float aa, const Float ab, const Float ac, const Float ad): |
45 Quaternion(const Float aa, const Float ab, const Float ac, const Float ad): |
46 a(aa), b(ab), c(ac), d(ad) {}; |
46 a(aa), b(ab), c(ac), d(ad) {}; |
47 Quaternion(const Vector3& v): a(0), b(v.x), c(v.y), d(v.z) {}; |
47 Quaternion(const Vector& v): a(0), b(v.x), c(v.y), d(v.z) {}; |
48 |
48 |
49 Vector3 toVector() { return Vector3(b, c, d); }; |
49 Vector toVector() { return Vector(b, c, d); }; |
50 |
50 |
51 Quaternion normalize() |
51 Quaternion normalize() |
52 { |
52 { |
53 Float f = (Float)1.0f / sqrtf(a * a + b * b + c * c + d * d); |
53 Float f = (Float)1.0f / sqrtf(a * a + b * b + c * c + d * d); |
54 a *= f; |
54 a *= f; |