Nodes to convert between cartesian/spherical coordinates #94722

Open
opened 2022-01-07 18:36:15 +01:00 by Simon Thommes · 15 comments
Member

There should be nodes to convert between spherical and cartesian coordinates in a standardized way.

This point came up when discussing D12746 .

They are multiple design aspects to be figured out:

  • Node layout
  • Naming and Scope
  • Units
  • Value Ranges
There should be nodes to convert between spherical and cartesian coordinates in a standardized way. This point came up when discussing [D12746](https://archive.blender.org/developer/D12746) . They are multiple design aspects to be figured out: - Node layout - Naming and Scope - Units - Value Ranges
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @SimonThommes

Added subscriber: @SimonThommes
Author
Member

For usability I would suggest the following definitions:

  • Node layout:
    • Like Separate/Combine XYZ
  • Naming and Scope:
    • Components: Radius/Zenith/Azimuth -> R/Theta/Phi
    • Maybe this could also be solved with more generic Combine/Separate Vector nodes that can have different 3D coordinate modes. E.g. Cartesian (X/Y/Z) (->default), Spherical (R/Phi/Theta), Cylindrical (Rho,Phi,Z)
  • Units: Radians, shown as deg for the UI (same as e.g. Vector Rotate)
  • Value Ranges: Phi [-pi, pi], Theta [-pi/2, pi/2]

Math:
x = R*cos(Phi)cos(Theta)
y = R
sin(Phi)cos(Theta)
z = R
sin(Theta)

For usability I would suggest the following definitions: - Node layout: - Like Separate/Combine XYZ - Naming and Scope: - Components: Radius/Zenith/Azimuth -> R/Theta/Phi - Maybe this could also be solved with more generic `Combine/Separate Vector` nodes that can have different 3D coordinate modes. E.g. Cartesian (X/Y/Z) (->default), Spherical (R/Phi/Theta), Cylindrical (Rho,Phi,Z) - Units: Radians, shown as deg for the UI (same as e.g. Vector Rotate) - Value Ranges: Phi [-pi, pi], Theta [-pi/2, pi/2] Math: x = R*cos(Phi)*cos(Theta) y = R*sin(Phi)*cos(Theta) z = R*sin(Theta) - > Behavior like in this file: [separate_combine_vector.blend](https://archive.blender.org/developer/F12793103/separate_combine_vector.blend) ![image.png](https://archive.blender.org/developer/F12793099/image.png)

Added subscriber: @GeorgiaPacific

Added subscriber: @GeorgiaPacific
Member

Added subscriber: @CharlieJolly

Added subscriber: @CharlieJolly
Member
WIP patch here: [D13772: (WIP) Node: Add Vector Convert node](https://archive.blender.org/developer/D13772)

Added subscriber: @zNight

Added subscriber: @zNight

Added subscriber: @sozap

Added subscriber: @sozap
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Member

Testing D12746, I started to think that this is really the more important node to include short term.

Node Layout

The three inputs and an enum for the conversion make sense to me.

Node Name
Calling the node "Combine Vector" sounds too general in my opinion. Combining the "Combine XYZ" functionality with something like converting to spherical coordinates doesn't seem ideal, since one is very simple, and one is a much more complicated operation.
The name then wouldn't tell you much about what the node does.

I would suggest a name like "Convert Vector" or "Spherical Coordinates". The former is nice because it fits with cylindrical coordinates and it's phrased like an action.

Socket Names
For naming, I also think there's no need to use math variable names like Phi and Theta, we should just use the proper terms directly-- "Radius", "Zenith", and "Azimuth".

Units/Ranges

Everything Simon proposes here makes sense to me too.

Testing [D12746](https://archive.blender.org/developer/D12746), I started to think that this is really the more important node to include short term. **Node Layout** The three inputs and an enum for the conversion make sense to me. **Node Name** Calling the node "Combine Vector" sounds too general in my opinion. Combining the "Combine XYZ" functionality with something like converting to spherical coordinates doesn't seem ideal, since one is *very* simple, and one is a much more complicated operation. The name then wouldn't tell you much about what the node does. I would suggest a name like "Convert Vector" or "Spherical Coordinates". The former is nice because it fits with cylindrical coordinates and it's phrased like an action. **Socket Names** For naming, I also think there's no need to use math variable names like Phi and Theta, we should just use the proper terms directly-- "Radius", "Zenith", and "Azimuth". **Units/Ranges** Everything Simon proposes here makes sense to me too.
Author
Member

Hm. This might be personal bias due to my physics background, but to me combining a vector socket from 3 components is fundamentally the same operation regardless of the used coordinate system.
Sure, in the code the cartesian system is used for everything, but I personally would prefer if a more agnostic approach.

This ties into the fact that conceptually there is no such thing as a cartesian vector or a spherical vector. A 3D vector can just be represented in different coordinate systems. So coming from that, to me it makes most sense to have general combine/separate vector nodes where the system can be chosen. Rather than having multiple nodes that have fundamentally the same purpose with very different names.

Hm. This might be personal bias due to my physics background, but to me combining a vector socket from 3 components is fundamentally the same operation regardless of the used coordinate system. Sure, in the code the cartesian system is used for everything, but I personally would prefer if a more agnostic approach. This ties into the fact that conceptually there is no such thing as a cartesian vector or a spherical vector. A 3D vector can just be represented in different coordinate systems. So coming from that, to me it makes most sense to have general combine/separate vector nodes where the system can be chosen. Rather than having multiple nodes that have fundamentally the same purpose with very different names.
Member

I've been looking at Sverchok recently and they use Compose/Decompose for this. For coordinate system, this could also be other data types like color e.g. HSL
So question is if the node should be generalized into a compose/decompose vector type node with different modes or if we have pairs of nodes for each conversion?

Edit:
@HooglyBoogly @SimonThommes
Due to discussion in D14034: Geometry/Compositor/Shader/Texture Nodes: Add general Combine/Separate Color nodes, shall I change D13772: (WIP) Node: Add Vector Convert node so that it just expands functionality of existing separate/combine xyz by adding modes and call it separate/combine vector? Or is this one of those nodes that should be shipped as an asset bundle?

I've been looking at Sverchok recently and they use Compose/Decompose for this. For coordinate system, this could also be other data types like color e.g. HSL So question is if the node should be generalized into a compose/decompose vector type node with different modes or if we have pairs of nodes for each conversion? Edit: @HooglyBoogly @SimonThommes Due to discussion in [D14034: Geometry/Compositor/Shader/Texture Nodes: Add general Combine/Separate Color nodes](https://archive.blender.org/developer/D14034), shall I change [D13772: (WIP) Node: Add Vector Convert node](https://archive.blender.org/developer/D13772) so that it just expands functionality of existing separate/combine xyz by adding modes and call it separate/combine vector? Or is this one of those nodes that should be shipped as an asset bundle?
Member

but to me combining a vector socket from 3 components is fundamentally the same operation regardless of the used coordinate system.

This is getting a bit theoretical, but I don't think this is the way typical users will think about these operations. Spherical coordinates are much more complicated, they're the "other", the "non-standard", and I think it would be expected that this is reflected in the UI.

This ties into the fact that conceptually there is no such thing as a cartesian vector or a spherical vector.

This might be technically true, but at every point in a node tree, doesn't a certain vector have a semantic meaning as well? That would include its coordinate system. Node link data is useless without that semantic meaning, so I'd personally consider it "part of the data", at least that's how it ends up working practically.

I like the names "Compose/Decompose" that @CharlieJolly mentioned above. "Decompose Vector" and "Compose Vector" sound reasonable. But if we end up calling this "Combine Vector", well it's certainly not the end of the world :)


So question is if the node should be generalized into a compose/decompose vector type node with different modes or if we have pairs of nodes for each conversion?

Personally I think that would be taking the generic typed node idea too far, beyond what's actually useful conceptually. Combining colors and vectors are quite different.
If we end up adding a 2D vector socket, I think that could still be included in this node, but IMO a color node should still be separate.

>but to me combining a vector socket from 3 components is fundamentally the same operation regardless of the used coordinate system. This is getting a bit theoretical, but I don't think this is the way typical users will think about these operations. Spherical coordinates are much more complicated, they're the "other", the "non-standard", and I think it would be expected that this is reflected in the UI. >This ties into the fact that conceptually there is no such thing as a cartesian vector or a spherical vector. This might be technically true, but at every point in a node tree, doesn't a certain vector have a semantic meaning as well? That would include its coordinate system. Node link data is useless without that semantic meaning, so I'd personally consider it "part of the data", at least that's how it ends up working practically. I like the names "Compose/Decompose" that @CharlieJolly mentioned above. "Decompose Vector" and "Compose Vector" sound reasonable. But if we end up calling this "Combine Vector", well it's certainly not the end of the world :) --- > So question is if the node should be generalized into a compose/decompose vector type node with different modes or if we have pairs of nodes for each conversion? Personally I think that would be taking the generic typed node idea too far, beyond what's actually useful conceptually. Combining colors and vectors are quite different. If we end up adding a 2D vector socket, I think that could still be included in this node, but IMO a color node should still be separate.
Author
Member

@HooglyBoogly I'm getting a bit lost in what you are proposing. It seems to me that while we are disagreeing on the reasoning an a fundamental level, we are combing to the same conclusions on what this node should look like. That makes it a bit confusing to me.

Maybe we can just clear up the confusion in a meeting and get back to this thread. I'll put the topic on the agenda.

@HooglyBoogly I'm getting a bit lost in what you are proposing. It seems to me that while we are disagreeing on the reasoning an a fundamental level, we are combing to the same conclusions on what this node should look like. That makes it a bit confusing to me. Maybe we can just clear up the confusion in a meeting and get back to this thread. I'll put the topic on the agenda.
Member

Copying from the meeting nodes here:

  • We had a long discussion (with some misunderstandings) about how vectors should still be stored in cartesian coordinates, and vectors shouldn't become a "bag of floats"
  • Color and vector should be separate nodes
  • Rename "Combine/Separate XYZ" to "Combine/Separate Vector"
  • Add "Cartesian", "Spherical", and "Cylindrical" options to both nodes
  • Socket Names: "Radius", "Azimuth", "Zenith"
  • Zenith has a soft range from -π/2 to 0 (at the horizon) to π/2.
  • Azimuth has no soft range (but for the output is wrapped from -π to π)
  • Radius has a soft limit of zero, but negative radii are flipped.'
  • Don't change the node ID names, since they're still basically correct and are probably used in a lot of scripts.
Copying from the meeting nodes here: >* We had a long discussion (with some misunderstandings) about how vectors should still be stored in cartesian coordinates, and vectors shouldn't become a "bag of floats" >* Color and vector should be separate nodes >* Rename "Combine/Separate XYZ" to "Combine/Separate Vector" >* Add "Cartesian", "Spherical", and "Cylindrical" options to both nodes >* Socket Names: "Radius", "Azimuth", "Zenith" >* Zenith has a soft range from -π/2 to 0 (at the horizon) to π/2. >* Azimuth has no soft range (but for the output is wrapped from -π to π) >* Radius has a soft limit of zero, but negative radii are flipped.' >* Don't change the node ID names, since they're still basically correct and are probably used in a lot of scripts.
Johnny Matthews self-assigned this 2022-08-09 21:51:01 +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
6 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#94722
No description provided.