New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add common matrix functions to standard library #1538
Conversation
± Registry diff
📊 PerformanceKeyNote that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.
If a row has only one bar instead of four, that means it's not a trio and the bar just shows the total time spent for that example, again rounded up to the nearest 100ms. Data
|
Deploying with Cloudflare Pages
|
…nto matrix-library
add warning box around matrix indexing note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these functions and the great examples @keenancrane! Really appreciated the effort to document and test them. I'm sure they will enable many more diagrams soon!
I pushed one commit to tweak the documentation, and have some questions about vouter
and error-handling. Hoping you can explain the former and @liangyiliang can possibly confirm the latter.
@wodeni I believe I've fixed your requested changes, and also updated the vim highlighting files with my local ones (the ones in the repo were long out of date…). Let me know if there's anything else! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great. thanks @keenancrane!
This PR adds common matrix functions, including 2D/3D transformations and camera matrices, to the library. It also adds corresponding documentation, tests and examples, and a language feature
then
for left-to-right composition of transformations.New functions
New functions added to
Functions.ts
are listed below. See the newVectors and Matrices
page in the Documentation, as well as the generated Function Library documentation, for further details. (Design decisions for the naming conventions are also spelled out int his documentation.)fromHomogeneous
fromHomogeneousList
toHomogeneous
toHomogeneousList
toHomogeneousMatrix
rotate
scale
skew
shear
translate
rotate2d
scale2d
skew2d
shear2d
rotate3d
scale3d
shear3d
rotate3dh
scale3dh
shear
translate3dh
lookAt
perspective
ortho
project
projectDepth
projectList
matrixMultiplyList
New language features
This PR adds the
then
keyword to the Style parser/compiler. This keyword is equivalent to the*
operator, except that it reverses the order of the arguments, i.e.,A then B
is equilvalent toB * A
. The main use case, as highlighted in the documentation, is to compose transformations in "natural language order", i.e., left to right. For instance, just as one can say "flip it over and put it in the oven" to mean "flip first, put in oven second," one can also writeTests and examples
The
triangle-mesh-3d
example has been updated to use the new 3D transformations and camera matrices.A new example,
dinoshade
, has also been added, with an extensive README that serves as a "Style for OpenGL Programmers" guide.All the new matrix functions come with a suite of corresponding tests, in the
examples/matrix-library/
. These examples use the "red/green" testing paradigm, as explained inexamples/matrix-library/README.md
. The particular tests arecrossProductMatrix.trio.json
diagonal2d.trio.json
diagonal3d.trio.json
identity2d.trio.json
identity3d.trio.json
inverse2d.trio.json
inverse3d.trio.json
matrix2d.trio.json
matrix3d.trio.json
outerProduct2d.trio.json
outerProduct3d.trio.json
rotate.trio.json
rotate2d.trio.json
rotate3d.trio.json
rotate3dh.trio.json
scale2d.trio.json
scale3d.trio.json
shear2d.trio.json
shear3d.trio.json
skew2d.trio.json
translate2d.trio.json
translate3dh.trio.json
Documentation
As noted above, extensive documentation for new functionality has been added in
Vectors and Matrices
page of the documentation, which has also refactored documentation on vector/matrix types and operations from the Style Usage page, anddinoshade
example, which provides a step-by-step tutorial on usage of 3d transformation and camera matrices.