Skip to content
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

NF: More view and math tools #2870

Merged
merged 26 commits into from
Jul 17, 2020
Merged

NF: More view and math tools #2870

merged 26 commits into from
Jul 17, 2020

Conversation

mdcutone
Copy link
Member

@mdcutone mdcutone commented May 26, 2020

Some additional view and math tools.

Changes to viewtools

  • Added visualAngle which computes visual angle using vector inputs.
  • Added visible and visibleBBox which are fast functions for testing whether points or bounding volumes are visible in the current projection.
  • Added computeFrustumFOV which gives a frustum much like gluPerspective does.
  • Added projectFrustum and projectFrustumToPlane which is used to determine the dimensions of the projection of a frustum on a screen or surface. Used for determining the drawing area when viewing through an aperture, but more generally, the size of a plane the frustum projects to at some distance.

Changes to mathtools

  • Added normalMatrix to compute the normal matrix used for lighting calculations in fragment shaders.
  • Added fitBBox and computeBBoxCorners for fitting axis-aligned bounding boxes to a group of points or vertices. Used with visible and visibleBBox as well as the various raypicking routines in mathtools.
  • Added multMatrix for fast chain multiplication of matrices.
  • rotationMatrix and quatFromAxisAngle now accepts string names as a shorthand for rotations about world axes (eg. -x, +z, etc.)
  • Added scale function for uniform and anisotropic scaling of points.
  • Added accumQuat for accumulating quaternion rotations. Used for forward-kinematics and armatures.
  • Added zeroFix to truncate numbers in arrays close to zero to zero.
  • Optimization of invertMatrix to invert affine/orthogonal matrices faster. Also handles inverting other matrices with different shapes. Useful for color space transforms which typically have 3x3 matrices.
  • BF: isAffine strictly works with only 4x4 matrices, raised no error before.
  • Added 'fixTangentHandedness` to enforce handedness of tangent vectors for 3D models with messed up UV coordinates.
  • Added articulate for forward-kinematics.
  • Added unproject for getting object coordinates from screen and depth buffer coords.

@coveralls
Copy link

coveralls commented May 26, 2020

Coverage Status

Coverage decreased (-0.3%) to 47.046% when pulling 7e94771 on mdcutone:more-tools into 6f6ec9a on psychopy:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 47.408% when pulling d9abdd8 on mdcutone:more-tools into 5e1334f on psychopy:master.

@codecov-commenter
Copy link

codecov-commenter commented May 26, 2020

Codecov Report

Merging #2870 into master will increase coverage by 0.26%.
The diff coverage is 19.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2870      +/-   ##
==========================================
+ Coverage   42.77%   43.04%   +0.26%     
==========================================
  Files         255      255              
  Lines       47425    48200     +775     
  Branches     8132     8174      +42     
==========================================
+ Hits        20287    20747     +460     
- Misses      24993    25305     +312     
- Partials     2145     2148       +3     
Impacted Files Coverage Δ
psychopy/visual/stim3d.py 26.59% <0.00%> (+6.68%) ⬆️
psychopy/tools/viewtools.py 33.33% <10.61%> (-21.56%) ⬇️
psychopy/tools/mathtools.py 38.54% <26.41%> (-3.96%) ⬇️
psychopy/experiment/components/static/__init__.py 74.74% <0.00%> (-7.08%) ⬇️
psychopy/experiment/components/form/__init__.py 88.00% <0.00%> (-3.90%) ⬇️
psychopy/visual/backends/pygamebackend.py 62.02% <0.00%> (-3.31%) ⬇️
psychopy/app/runner/scriptProcess.py 26.66% <0.00%> (-1.25%) ⬇️
psychopy/app/themes/_themes.py 73.17% <0.00%> (-0.65%) ⬇️
psychopy/hardware/qmix.py 2.56% <0.00%> (-0.33%) ⬇️
psychopy/visual/rift.py 2.48% <0.00%> (-0.15%) ⬇️
... and 62 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f6ec9a...7e94771. Read the comment docs.

@lgtm-com
Copy link

lgtm-com bot commented May 27, 2020

This pull request introduces 1 alert when merging 569abc2 into 5e1334f - view on LGTM.com

new alerts:

  • 1 for Wrong name for an argument in a call

@lgtm-com
Copy link

lgtm-com bot commented May 27, 2020

This pull request introduces 1 alert when merging fc887c3 into 5e1334f - view on LGTM.com

new alerts:

  • 1 for Wrong name for an argument in a call

@lgtm-com
Copy link

lgtm-com bot commented Jun 3, 2020

This pull request introduces 1 alert when merging 7456df3 into ae4c720 - view on LGTM.com

new alerts:

  • 1 for Redundant assignment

@lgtm-com
Copy link

lgtm-com bot commented Jul 2, 2020

This pull request introduces 1 alert when merging 4397a5a into 6e6e62f - view on LGTM.com

new alerts:

  • 1 for Redundant assignment

@lgtm-com
Copy link

lgtm-com bot commented Jul 15, 2020

This pull request introduces 1 alert when merging a68af85 into 6f6ec9a - view on LGTM.com

new alerts:

  • 1 for Redundant assignment

@peircej
Copy link
Member

peircej commented Jul 16, 2020

That's very odd error on Travis:

>    @pytest.mark.mathtools
>    def test_invertMatrix():
>       ...
>           inv = invertMatrix(m, homogeneous=True)

E           TypeError: invertMatrix() got an unexpected keyword argument 'homogeneous'
psychopy/tests/test_tools/test_mathtools.py:345: TypeError

but homogeneous is clearly there in the def

@mdcutone
Copy link
Member Author

Okay I'll fix it.

@peircej peircej merged commit 939fcd6 into psychopy:master Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants