@@ -66,6 +66,82 @@ static assert(dimension > 0, "0 dimensional vectors don't exist.");
66
66
size_t toHash () const { return typeid (this ).getHash(&this ); }
67
67
68
68
@safe pure nothrow :
69
+
70
+ /**
71
+ A vector with all zeroes
72
+ */
73
+ static auto zero () {
74
+ return Vector! (type, dimension_)(0 );
75
+ }
76
+
77
+ /**
78
+ A vector with all ones
79
+ */
80
+ static auto one () {
81
+ return Vector! (type, dimension_)(1 );
82
+ }
83
+
84
+ /**
85
+ Up vector (0, -1) OR (0, 1, 0)
86
+ */
87
+ static auto up () {
88
+ static if (dimension_ == 2 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)- 1 );
89
+ else static if (dimension_ == 3 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)1 , cast (type)0 );
90
+ else static if (dimension_ == 4 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)1 , cast (type)0 , cast (type)0 );
91
+ else return Vector! (type, dimension_).init;
92
+ }
93
+
94
+ /**
95
+ Down vector (0, 1) OR (0, -1, 0)
96
+ */
97
+ static auto down () {
98
+ static if (dimension_ == 2 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)1 );
99
+ else static if (dimension_ == 3 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)- 1 , cast (type)0 );
100
+ else static if (dimension_ == 4 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)- 1 , cast (type)0 , cast (type)0 );
101
+ else return Vector! (type, dimension_).init;
102
+ }
103
+
104
+ /**
105
+ Left vector (-1, 0, 0)
106
+ */
107
+ static auto left () {
108
+ static if (dimension_ == 2 ) return Vector! (type, dimension_)(cast (type)- 1 , cast (type)0 );
109
+ else static if (dimension_ == 3 ) return Vector! (type, dimension_)(cast (type)- 1 , cast (type)0 , cast (type)0 );
110
+ else static if (dimension_ == 4 ) return Vector! (type, dimension_)(cast (type)- 1 , cast (type)0 , cast (type)0 , cast (type)0 );
111
+ else return Vector! (type, dimension_).init;
112
+ }
113
+
114
+ /**
115
+ Right vector (1, 0, 0)
116
+ */
117
+ static auto right () {
118
+ static if (dimension_ == 2 ) return Vector! (type, dimension_)(cast (type)1 , cast (type)0 );
119
+ else static if (dimension_ == 3 ) return Vector! (type, dimension_)(cast (type)1 , cast (type)0 , cast (type)0 );
120
+ else static if (dimension_ == 4 ) return Vector! (type, dimension_)(cast (type)1 , cast (type)0 , cast (type)0 , cast (type)0 );
121
+ else return Vector! (type, dimension_).init;
122
+ }
123
+
124
+ static if (dimension_ >= 3 ) {
125
+
126
+ /**
127
+ Forward vector (0, 0, 1)
128
+ */
129
+ static auto forward () {
130
+ static if (dimension_ == 3 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)0 , cast (type)1 );
131
+ else static if (dimension_ == 4 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)0 , cast (type)1 , cast (type)0 );
132
+ else return Vector! (type, dimension_).init;
133
+ }
134
+
135
+ /**
136
+ Back vector (0, 0, -1)
137
+ */
138
+ static auto back () {
139
+ static if (dimension_ == 3 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)0 , cast (type)- 1 );
140
+ else static if (dimension_ == 4 ) return Vector! (type, dimension_)(cast (type)0 , cast (type)0 , cast (type)- 1 , cast (type)0 );
141
+ else return Vector! (type, dimension_).init;
142
+ }
143
+ }
144
+
69
145
// /
70
146
ref inout (vt) get_ (char coord)() inout {
71
147
return vector[coordToIndex! coord];
@@ -199,7 +275,6 @@ static assert(dimension > 0, "0 dimensional vectors don't exist.");
199
275
return true ;
200
276
}
201
277
}
202
- deprecated (" Use isFinite instead of ok" ) alias ok = isFinite;
203
278
204
279
// / Sets all values of the vector to value.
205
280
void clear (vt value) {
0 commit comments