1 /********************************************************************** 2 Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved. 3 4 Permission is hereby granted, free of charge, to any person obtaining a copy 5 of this software and associated documentation files (the "Software"), to deal 6 in the Software without restriction, including without limitation the rights 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 copies of the Software, and to permit persons to whom the Software is 9 furnished to do so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included in 12 all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 THE SOFTWARE. 21 ********************************************************************/ 22 module radeonrays.math.float2; 23 24 extern(C++,"RadeonRays") 25 { 26 struct float2 27 { 28 public: 29 /*float2(float xx = 0.f, float yy = 0.f) : x(xx), y(yy) {} 30 31 float& operator [](int i) { return *(&x + i); } 32 float operator [](int i) const { return *(&x + i); } 33 float2 operator-() const { return float2(-x, -y); } 34 35 float sqnorm() const { return x*x + y*y; } 36 void normalize() { (*this)/=(std::sqrt(sqnorm()));} 37 38 float2& operator += (float2 const& o) { x+=o.x; y+=o.y; return *this; } 39 float2& operator -= (float2 const& o) { x-=o.x; y-=o.y; return *this; } 40 float2& operator *= (float2 const& o) { x*=o.x; y*=o.y; return *this; } 41 float2& operator *= (float c) { x*=c; y*=c; return *this; } 42 float2& operator /= (float c) { float cinv = 1.f/c; x*=cinv; y*=cinv; return *this; }*/ 43 44 float x, y; 45 }; 46 47 /* 48 inline float2 operator+(float2 const& v1, float2 const& v2) 49 { 50 float2 res = v1; 51 return res+=v2; 52 } 53 54 inline float2 operator-(float2 const& v1, float2 const& v2) 55 { 56 float2 res = v1; 57 return res-=v2; 58 } 59 60 inline float2 operator*(float2 const& v1, float2 const& v2) 61 { 62 float2 res = v1; 63 return res*=v2; 64 } 65 66 inline float2 operator*(float2 const& v1, float c) 67 { 68 float2 res = v1; 69 return res*=c; 70 } 71 72 inline float2 operator*(float c, float2 const& v1) 73 { 74 return operator*(v1, c); 75 } 76 77 inline float dot(float2 const& v1, float2 const& v2) 78 { 79 return v1.x * v2.x + v1.y * v2.y; 80 } 81 82 inline float2 normalize(float2 const& v) 83 { 84 float2 res = v; 85 res.normalize(); 86 return res; 87 } 88 89 inline float2 vmin(float2 const& v1, float2 const& v2) 90 { 91 return float2(std::min(v1.x, v2.x), std::min(v1.y, v2.y)); 92 } 93 94 95 inline float2 vmax(float2 const& v1, float2 const& v2) 96 { 97 return float2(std::max(v1.x, v2.x), std::max(v1.y, v2.y)); 98 }*/ 99 }