Subversion Repositories gelsvn

Rev

Rev 633 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 633 Rev 634
Line 66... Line 66...
66
        {
66
        {
67
            std::fill_n(data, N, _a);
67
            std::fill_n(data, N, _a);
68
        }
68
        }
69
        
69
        
70
        /// Construct a 2D vector
70
        /// Construct a 2D vector
71
        ArithVec(T _a, T _b): data({_a,_b}) {assert(N==2);}
71
        ArithVec(T _a, T _b)
72
        
72
        {
73
        /// Construct a 2D vector
73
            assert(N==2);
-
 
74
            data[0] = _a;
74
        ArithVec(T _a, T _b, T _c): data({_a,_b,_c}) {assert(N==3);}
75
            data[1] = _b;
-
 
76
        }
75
        
77
        
76
        /// Construct a 2D vector
78
        /// Construct a 3D vector
77
        ArithVec(T _a, T _b, T _c, T _d): data({_a,_b,_c,_d}) {assert(N==4);}
79
        ArithVec(T _a, T _b, T _c)
-
 
80
        {
-
 
81
            assert(N==3);
-
 
82
            data[0] = _a;
-
 
83
            data[1] = _b;
-
 
84
            data[2] = _c;
-
 
85
        }
78
        
86
        
-
 
87
        /// Construct a 4D vector
-
 
88
        ArithVec(T _a, T _b, T _c, T _d)
-
 
89
        {
-
 
90
            assert(N==4);
-
 
91
            data[0] = _a;
-
 
92
            data[1] = _b;
-
 
93
            data[2] = _c;
-
 
94
            data[3] = _d;
-
 
95
        }
79
    public:
96
    public:
80
        
97
        
81
        /// For convenience we define a more meaningful name for the scalar type
98
        /// For convenience we define a more meaningful name for the scalar type
82
        typedef T ScalarType;
99
        typedef T ScalarType;
83
        
100
        
Line 89... Line 106...
89
        
106
        
90
        /// Set all coordinates of a 2D vector.
107
        /// Set all coordinates of a 2D vector.
91
        void set(T _a, T _b)
108
        void set(T _a, T _b)
92
        {
109
        {
93
            assert(N==2);
110
            assert(N==2);
-
 
111
            data[0] = _a;
94
            data = {_a,_b};
112
            data[1] = _b;
95
        }
113
        }
96
        
114
        
97
        /// Set all coordinates of a 3D vector.
115
        /// Set all coordinates of a 3D vector.
98
        void set(T _a, T _b, T _c)
116
        void set(T _a, T _b, T _c)
99
        {
117
        {
100
            assert(N==3);
118
            assert(N==3);
-
 
119
            data[0] = _a;
-
 
120
            data[1] = _b;
101
            data = {_a,_b,_c};
121
            data[2] = _c;
102
        }
122
        }
103
        
123
        
104
        /// Set all coordinates of a 4D vector.
124
        /// Set all coordinates of a 4D vector.
105
        void set(T _a, T _b, T _c, T _d)
125
        void set(T _a, T _b, T _c, T _d)
106
        {
126
        {
107
            assert(N==4);
127
            assert(N==4);
-
 
128
            data[0] = _a;
-
 
129
            data[1] = _b;
-
 
130
            data[2] = _c;
108
            data = {_a,_b,_c,_d};
131
            data[3] = _d;
109
        }
132
        }
110
        
133
        
111
        /// Const index operator
134
        /// Const index operator
112
        const T& operator [] ( unsigned int i ) const
135
        const T& operator [] ( unsigned int i ) const
113
        {
136
        {