Skip to content

Commit 00b308c

Browse files
committed
v0.9.0 - added access to iterators for vector_base -- name refactored the duck type interface for the vectors -- added a few iterator tests
1 parent f6e1a67 commit 00b308c

File tree

5 files changed

+241
-174
lines changed

5 files changed

+241
-174
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ This may be a single header library, but if Visual Studio is being used, we reco
174174

175175
## Status
176176

177-
Current version: `v0.8.14`
177+
Current version: `v0.9.0`
178178

179179
* **All the vector and matrix functionality is implemented.**
180180
* First pass at test coverage. Everything major has some tests, but code coverage is not 100%.
181-
* [Released v0.8.0](https://github.com/davidbrowne/dsga/releases/tag/v0.8.0)
181+
* [Released v0.9.0](https://github.com/davidbrowne/dsga/releases/tag/v0.9.0)
182182

183183
### The next steps
184184
* 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).
195195

196196
This project uses [doctest](https://github.com/onqtam/doctest) for testing. We occasionally use [nanobench](https://github.com/martinus/nanobench) for understanding implementation tradeoffs.
197197

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<>```.
199199

200200
The tests have been most recently run on:
201201

@@ -207,8 +207,8 @@ The tests have been most recently run on:
207207
[doctest] doctest version is "2.4.9"
208208
[doctest] run with "--help" for options
209209
===============================================================================
210-
[doctest] test cases: 84 | 84 passed | 0 failed | 0 skipped
211-
[doctest] assertions: 1890 | 1890 passed | 0 failed |
210+
[doctest] test cases: 85 | 85 passed | 0 failed | 0 skipped
211+
[doctest] assertions: 1894 | 1894 passed | 0 failed |
212212
[doctest] Status: SUCCESS!
213213
```
214214

@@ -218,8 +218,8 @@ The tests have been most recently run on:
218218
[doctest] doctest version is "2.4.9"
219219
[doctest] run with "--help" for options
220220
===============================================================================
221-
[doctest] test cases: 84 | 84 passed | 0 failed | 0 skipped
222-
[doctest] assertions: 1890 | 1890 passed | 0 failed |
221+
[doctest] test cases: 85 | 85 passed | 0 failed | 0 skipped
222+
[doctest] assertions: 1894 | 1894 passed | 0 failed |
223223
[doctest] Status: SUCCESS!
224224
```
225225

@@ -231,8 +231,8 @@ Performs all the unit tests except where there is lack of support for ```std::is
231231
[doctest] doctest version is "2.4.9"
232232
[doctest] run with "--help" for options
233233
===============================================================================
234-
[doctest] test cases: 84 | 84 passed | 0 failed | 0 skipped
235-
[doctest] assertions: 1874 | 1874 passed | 0 failed |
234+
[doctest] test cases: 85 | 85 passed | 0 failed | 0 skipped
235+
[doctest] assertions: 1878 | 1878 passed | 0 failed |
236236
[doctest] Status: SUCCESS!
237237
```
238238

@@ -244,8 +244,8 @@ Performs all the unit tests except where there is lack of support for ```std::is
244244
[doctest] doctest version is "2.4.9"
245245
[doctest] run with "--help" for options
246246
===============================================================================
247-
[doctest] test cases: 84 | 84 passed | 0 failed | 0 skipped
248-
[doctest] assertions: 1890 | 1890 passed | 0 failed |
247+
[doctest] test cases: 85 | 85 passed | 0 failed | 0 skipped
248+
[doctest] assertions: 1894 | 1894 passed | 0 failed |
249249
[doctest] Status: SUCCESS!
250250
```
251251

@@ -275,8 +275,8 @@ dsga/tests/swizzle_test.cxx:1849: ERROR: CHECK_UNARY( std::is_trivial_v<dmat4> )
275275
values: CHECK_UNARY( false )
276276
277277
===============================================================================
278-
[doctest] test cases: 84 | 83 passed | 1 failed | 0 skipped
279-
[doctest] assertions: 1874 | 1872 passed | 2 failed |
278+
[doctest] test cases: 85 | 84 passed | 1 failed | 0 skipped
279+
[doctest] assertions: 1878 | 1876 passed | 2 failed |
280280
[doctest] Status: FAILURE!
281281
```
282282

docs/DOCUMENTATION.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ vec4 big_vec;
130130
vec3 smaller_vec(big_vec.zyx);
131131
```
132132
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.
134134
135135
A length 1 vector can only refer to "x", but it can do so up to 4 times in a swizzle:
136136
```c++
@@ -194,6 +194,7 @@ The matrix types are very generic. One can pre-mulitply (matrix on left, vector
194194
# API
195195

196196
* Matrices and Vectors
197+
* [Index Interface](#index-interface)
197198
* [Iterators](#iterators)
198199
* [Tuple Interface](#tuple-interface)
199200
* [Low Level Pointer Access](#low-level-pointer-access)
@@ -221,16 +222,22 @@ We have [enumerated all the specific classes](#types-and-functions) we support i
221222

222223
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.
223224

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+
224231
### Iterators
225232

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:
227234

228235
* Standard Library Algorithms
229236
* [Range-based for loop](https://en.cppreference.com/w/cpp/language/range-for)
230237

231238
### Tuple Interface
232239

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:
234241

235242
* Data structures in same manner as ```tuple```
236243
* [Structured Binding](https://en.cppreference.com/w/cpp/language/structured_binding)
@@ -239,9 +246,9 @@ Both the vector and matrix structs support **std::tuple_element<>**, **std::tupl
239246

240247
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:
241248

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.
245252

246253
## Vector
247254

@@ -308,12 +315,10 @@ This approach is exactly what ```basic_matrix``` does.
308315
309316
### Vector Member Functions
310317
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).
312319
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.
317322
318323
### Vector Operators
319324
The vector operators all work component-wise.

docs/vec_base_uml.svg

Lines changed: 50 additions & 48 deletions
Loading

0 commit comments

Comments
 (0)