You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Example projects: need small, medium, and large examples. The quick peek at the top of this page is a start, as is a [more detailed generic version of the example](docs/DETAILS.md#detailed-generic-example).
@@ -195,7 +195,7 @@ More in depth explanation can be found in the [details](docs/DETAILS.md).
195
195
196
196
This project uses [doctest](https://github.com/onqtam/doctest) for testing. We occasionally use [nanobench](https://github.com/martinus/nanobench) for understanding implementation tradeoffs.
197
197
198
-
Both MSVC and gcc (for Windows and on Ubuntu on WSL2) pass all the tests. clang for Windows passes, but there are 2 assertions out of 1874 that fail for clang-15 on Ubuntu, which appears to have a problem with ```std::is_trivial_v<>```.
198
+
Both MSVC and gcc (for Windows and on Ubuntu on WSL2) pass all the tests. clang for Windows passes, but there are 2 assertions out of 1878 that fail for clang-15 on Ubuntu, which appears to have a problem with ```std::is_trivial_v<>```.
199
199
200
200
The tests have been most recently run on:
201
201
@@ -207,8 +207,8 @@ The tests have been most recently run on:
Copy file name to clipboardExpand all lines: docs/DOCUMENTATION.md
+16-11Lines changed: 16 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,7 +130,7 @@ vec4 big_vec;
130
130
vec3 smaller_vec(big_vec.zyx);
131
131
```
132
132
133
-
Swizzling uses dot notation, e.g., ```foo.xy, bar.zw, baz.xxyy```. This gives you a type of vector that is a view on the data of the original vector. The swizzles are part of the original vector, and they have the same lifetime. The "x" index means the first value in the vector, "y" means the second, "z" means the third, and "w" means the fourth, so "xyzw" are the possible values in a swizzle, depending on the size of the original vector. In [GLSL](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf), there are 3 different domains for swizzling: ```xyzw```, ```rgba```, and ```stpq```. We use "xyzw" when talking about spatial coordinates, "rgba" when talking about color coordinates, and "stpq" when talking about texture coordinates. Since dsga is intended for geometry and algebra, we only bothered supporting **xyzw** for swizzling.
133
+
Swizzling uses dot notation, e.g., ```foo.xy, bar.zw, baz.xxyy```. This gives you a type of vector that is a view on the data of the original vector. The swizzles are part of the original vector, and they have the same lifetime. The "x" index means the first value in the vector, "y" means the second, "z" means the third, and "w" means the fourth, so "xyzw" are the possible values in a swizzle, depending on the size of the original vector. In [GLSL](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf), there are 3 different domains for swizzling: ```xyzw```, ```rgba```, and ```stpq```. We use "xyzw" when talking about spatial coordinates, "rgba" when talking about color coordinates, and "stpq" when talking about texture coordinates. Since dsga is intended for geometry and algebra, we only felt the need to support the "xyzw" set for swizzling.
134
134
135
135
A length 1 vector can only refer to "x", but it can do so up to 4 times in a swizzle:
136
136
```c++
@@ -194,6 +194,7 @@ The matrix types are very generic. One can pre-mulitply (matrix on left, vector
@@ -221,16 +222,22 @@ We have [enumerated all the specific classes](#types-and-functions) we support i
221
222
222
223
Please look at what is in the [GLSL spec](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf), especially Section 5 and Section 8, for a thorough look at the API. We will summarize what was implemented and how we supplemented matrix and vector.
223
224
225
+
### Index Interface
226
+
227
+
The vector structs closely model short versions of ```std::array```, including using ```operator []``` for access to scalar components. Matrix also has "operator []", but it is for accessing column vectors.
228
+
229
+
For vector swizzles, only *writable* swizzles can use ```operator []``` for write access to the vector.
230
+
224
231
### Iterators
225
232
226
-
Both the vector and matrix structs support **begin/cbegin/rbegin/crbegin** and **end/cend/rend/crend** iterator creation functions in order to provide non-const and const iterators. The ```indexed_vector``` iterators pass the ```std::random_access_iterator``` concept. This gives us access to:
233
+
Both the vector and matrix structs support ```begin()/cbegin()/rbegin()/crbegin()``` and ```end()/cend()/rend()/crend()``` iterator creation functions in order to provide non-const and const iterators. The ```indexed_vector``` iterators pass the ```std::random_access_iterator``` concept. This gives us access to:
227
234
228
235
* Standard Library Algorithms
229
236
*[Range-based for loop](https://en.cppreference.com/w/cpp/language/range-for)
230
237
231
238
### Tuple Interface
232
239
233
-
Both the vector and matrix structs support **std::tuple_element<>**, **std::tuple_size<>** and **get<>** in order to provide basic ```std::tuple``` support. This gives us access to:
240
+
Both the vector and matrix structs support ```std::tuple_element<>```, ```std::tuple_size<>``` and ```get<>``` in order to provide basic ```std::tuple``` support. This gives us access to:
@@ -239,9 +246,9 @@ Both the vector and matrix structs support **std::tuple_element<>**, **std::tupl
239
246
240
247
Both the vector and matrix structs support ```data()``` and ```size()``` in order to provide pointer access to the underlying data. The parameter pack returned by ```sequence()``` can also be helpful here to map the physical order from ```data()``` to the logical order (only useful for generic vector situations or when using ```indexed_vector```). *Hopefully*, no one wants to use pointer data to manipulate or access the data structures, but this approach exists if it is deemed appropriate:
241
248
242
-
***T \*data()** gives a pointer to the underlying vector elements or matrix columns, in physical order.
243
-
***std::size_t size()** gives the number of elements in the vector or number of columns in the matrix.
244
-
***std::index_sequence<Is...> sequence()** (only for vectors) gives a parameter pack that maps the physical order to the logical order. For a ```basic_vector``` those are the same, but for an ```indexed_vector``` they are mostly not the same. Pack expansion and folding are tools that might help with the low-level pointer access for vectors.
249
+
*```T *data()``` gives a pointer to the underlying vector elements or matrix columns, in physical order.
250
+
*```std::size_t size()``` gives the number of elements in the vector or number of columns in the matrix.
251
+
*```std::index_sequence<Is...> sequence()``` (only for vectors) gives a parameter pack that maps the physical order to the logical order. For a ```basic_vector``` those are the same, but for an ```indexed_vector``` they are mostly not the same. Pack expansion and folding are tools that might help with the low-level pointer access for vectors.
245
252
246
253
## Vector
247
254
@@ -308,12 +315,10 @@ This approach is exactly what ```basic_matrix``` does.
308
315
309
316
### Vector Member Functions
310
317
311
-
These are the members that are not part of the [iterator interface](#iterators), the [tuple interface](#tuple-interface), or the [low-level interface](#low-level-pointer-access).
318
+
These are the members that are not part of the [index interface](#index-interface), [iterator interface](#iterators), the [tuple interface](#tuple-interface), or the [low-level interface](#low-level-pointer-access).
312
319
313
-
* **operator =** - assignment operator. The vector needs to be the same length and underlying types must be convertible.
314
-
* **int length()** - returns the number of elements in a vector. This is part of the spec, and is the same as ```size()``` except it has a different return type.
315
-
* **operator []** - a generic way to access vector data. the ```x``` value is index 0, the ```y``` value is index 1, the ```z``` value is index 2, and the ```w``` value is index 3, assuming the vector is long enough to access those index values. Can be used for both reading and writing, assuming it isn't const or otherwise not allowed for writing.
316
-
* **set()** - this is the way of setting all the values for the vector at the same time. It takes the same number of scalar arguments as there are vector elements. This function is helpful at preventing trouble when there are potential aliasing problems.
320
+
* ```operator =``` - assignment operator. The vector needs to be the same length and underlying types must be convertible.
321
+
* ```int length()``` - returns the number of elements in a vector. This is part of the spec, and is the same as ```size()``` except it has a different return type.
0 commit comments