bpy Vectors comparison #43622

Closed
opened 2015-02-10 20:57:06 +01:00 by Giuseppe De Marco · 8 comments

System Information
Debian 8 - Jessie

Blender Version
bpy.app.build_hash: bbf09d9
bpy.app.version_string: '2.73 (sub 0)'

This isn't properly a bug, but I cannot understand what's happening here:

Writing a simple addon used for increase / decrease and set an
arbitrary edge length I'm learning the way that blender uses to work
with vertices and edges. I noticed this, in python console:

from mathutils import Vector

v3 = Vector((1.0, 0.0, 0.0))
v6 = Vector((-1.0, 0.0, 0.0))

v6 == v3
False

v6 > v3

False

v6 >= v3

True

Who could explain what's is the logical approach to this ?
Is there some arithmetic initial conditions that would be usefull to know before working with vertices ?

**System Information** Debian 8 - Jessie **Blender Version** bpy.app.build_hash: bbf09d9 bpy.app.version_string: '2.73 (sub 0)' This isn't properly a bug, but I cannot understand what's happening here: Writing a simple addon used for increase / decrease and set an arbitrary edge length I'm learning the way that blender uses to work with vertices and edges. I noticed this, in python console: ``` from mathutils import Vector v3 = Vector((1.0, 0.0, 0.0)) v6 = Vector((-1.0, 0.0, 0.0)) ``` v6 == v3 False >>> v6 > v3 False >>> v6 >= v3 True Who could explain what's is the logical approach to this ? Is there some arithmetic initial conditions that would be usefull to know before working with vertices ?

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @demarcog83

Added subscriber: @demarcog83
Sybren A. Stüvel self-assigned this 2015-02-10 21:14:22 +01:00

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Vector comparison is done in two ways. The == and != operators perform equality checks as you'd expect: v3 == v6 implies that all components are equal. However, component-wise ordering doesn't make sense, and <, >, <= and >= compare vector length instead. The result is that v3 > v6 or v3 == v6 is not the same as v3 >= v6.

Vector comparison is done in two ways. The `==` and `!=` operators perform equality checks as you'd expect: `v3 == v6` implies that all components are equal. However, component-wise ordering doesn't make sense, and `<`, `>`, `<=` and `>=` compare vector *length* instead. The result is that `v3 > v6 or v3 == v6` is not the same as `v3 >= v6`.

Thank you sybren,

This situation doesn't seems so rationale, I perfectly understood what you mean however there're many imperfections that could discourage users in deepen blender.

"""
The result is that v3 > v6 or v3 == v6 is not the same as v3 >= v6.
"""

In this case it should return always false, isn't so ?

For the addon I'm developing, mesh_edges_length.py, I start coding functions to do comparison of vectors in absolute values and other function to do vector comparison. Don't you think that these features should be configured as "primitives" in blender and not extended through python addons ?

Thank you sybren, This situation doesn't seems so rationale, I perfectly understood what you mean however there're many imperfections that could discourage users in deepen blender. """ The result is that v3 > v6 or v3 == v6 is not the same as v3 >= v6. """ In this case it should return always false, isn't so ? For the addon I'm developing, mesh_edges_length.py, I start coding functions to do comparison of vectors in absolute values and other function to do vector comparison. Don't you think that these features should be configured as "primitives" in blender and not extended through python addons ?

The absolute value of a vector is its length, so that's already in Blender. Implementing component-wise inequality (like >= per component) would need to return a Vector such that (a, b) >= (c, d) --> (a >= c, b >= d).

At this moment it's still quite an abstract discussion. Personally I wouldn't need this feature, as it goes against what I know of vectors (the mathematical concept, not the Blender class in particular). However, we welcome all improvements. If you have code that implements such features, and a good demonstration of why people need this, of course we'll look at it.

The absolute value of a vector *is* its length, so that's already in Blender. Implementing component-wise inequality (like `>=` per component) would need to return a Vector such that `(a, b) >= (c, d) --> (a >= c, b >= d)`. At this moment it's still quite an abstract discussion. Personally I wouldn't need this feature, as it goes against what I know of vectors (the mathematical concept, not the Blender class in particular). However, we welcome all improvements. If you have code that implements such features, and a good demonstration of why people need this, of course we'll look at it.

Thank you sybren

Thank you sybren

from bf-python ML :

Date: Tue, 10 Feb 2015 21:41:02 +0100
From: Sybren A. St?vel sybren@XxXXxXXXxl.eu
Subject: Re: [Bf-python] Vectors comparison doubts
To: Blender Foundation Python list bf-python@blender.org
Message-ID: 2685462.Pa2RXgPjun@herrie
Content-Type: text/plain; charset="utf-8"

On Tuesday 10 February 2015 09:22:56 Mark Young wrote:

?Unless something's changed since 2.49, when you do an equality check for
vectors, it does an element-wise comparison. When you use the inequality
operators, it does a magnitude comparison.

That's also what's currently happening.

Guiseppe's email did make me check the documentation, and I noticed a typo in
there, so that'll be fixed in the next Blender release too :)

from bf-python ML : Date: Tue, 10 Feb 2015 21:41:02 +0100 From: Sybren A. St?vel <sybren@XxXXxXXXxl.eu> Subject: Re: [Bf-python] Vectors comparison doubts To: Blender Foundation Python list <bf-python@blender.org> Message-ID: <2685462.Pa2RXgPjun@herrie> Content-Type: text/plain; charset="utf-8" On Tuesday 10 February 2015 09:22:56 Mark Young wrote: > ?Unless something's changed since 2.49, when you do an equality check for > vectors, it does an element-wise comparison. When you use the inequality > operators, it does a magnitude comparison. That's also what's currently happening. Guiseppe's email did make me check the documentation, and I noticed a typo in there, so that'll be fixed in the next Blender release too :)
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
2 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#43622
No description provided.