Math: Add from_up_axis matrix creation function #113218

Merged
Clément Foucault merged 3 commits from fclem/blender:math-matrix-from-up-axis into main 2023-10-04 14:35:55 +02:00

This add the possibility to create a
orthogonal basis around a given unit
vector.

The name was chosen to match the naming
convention already in place and match
the other matrix construction functions.
In other places (ex: renderers), this same
function is commonly named make_orthonormal
or make_basis.

The function is not given to have a fixed
implementation and might change overtime.
That's why the test only covers the
assumptions and not the raw values.

The implementation is borrowed from
Cycles and adapted to our math API.

This add the possibility to create a orthogonal basis around a given unit vector. The name was chosen to match the naming convention already in place and match the other matrix construction functions. In other places (ex: renderers), this same function is commonly named `make_orthonormal` or `make_basis`. The function is not given to have a fixed implementation and might change overtime. That's why the test only covers the assumptions and not the raw values. The implementation is borrowed from Cycles and adapted to our math API.
Clément Foucault added this to the 4.1 milestone 2023-10-03 19:08:48 +02:00
Clément Foucault added the
Interest
Core
Module
Core
labels 2023-10-03 19:08:48 +02:00
Clément Foucault self-assigned this 2023-10-03 19:08:49 +02:00
Clément Foucault added 1 commit 2023-10-03 19:09:01 +02:00
8353a8db8a Math: Matrix add `from_up_axis`
This add the possibility to create a
orthogonal basis around a given unit
vector.

The name was chosen to match the naming
convention already in place and match
the other matrix construction functions.
In other places (ex: renderers), this same
function is commonly named `make_orthonormal`
or `make_basis`.

The function is not given to have a fixed
implementation and might change overtime.
That's why the test only covers the
assumptions and not the raw values.

The implementation is borrowed from
Cycles and adapted to our math API.
Clément Foucault requested review from Sergey Sharybin 2023-10-03 19:10:19 +02:00
Clément Foucault requested review from Jacques Lucke 2023-10-03 19:10:20 +02:00
Clément Foucault added 1 commit 2023-10-03 19:15:18 +02:00
Sergey Sharybin approved these changes 2023-10-04 10:16:09 +02:00
@ -237,2 +247,4 @@
* In other words this removes the shear of the matrix. However this doesn't properly account for
* volume preservation, and so, the axes keep their respective length.
*
* \note Prefer using `from_up_axis` to create a orthogonal basis around a vector.

Not sure why would one use orthogonalize to create orthogonal basis.

Not sure why would one use `orthogonalize` to create orthogonal basis.
Author
Member

I added this comment because the name orthogonalize can cause confusion.

I added this comment because the name `orthogonalize` can cause confusion.
Jacques Lucke approved these changes 2023-10-04 10:57:12 +02:00
@ -276,1 +276,4 @@
EXPECT_TRUE(is_equal(m, expect, 0.00001f));
float3 up = normalize(float3(1, 2, 3));
m = from_up_axis<float4x4>(up);
Member

Guess we can also check that the resulting matrix has a determinant of 1?

Guess we can also check that the resulting matrix has a determinant of 1?
fclem marked this conversation as resolved
Clément Foucault added 1 commit 2023-10-04 13:59:27 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
e58c579360
Add determinant test as per review
Author
Member

@blender-bot build

@blender-bot build
Clément Foucault merged commit 9d229aee19 into main 2023-10-04 14:35:55 +02:00
Clément Foucault deleted branch math-matrix-from-up-axis 2023-10-04 14:35:57 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113218
No description provided.