Skip to content

[p5.js 2.0+ Bug Report]: Vector.equals() is quirky when dimensions are not equal #8929

@sidwellr

Description

@sidwellr

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.3.0

Web browser and version

Brave 1.90.122

Operating system

Linux Mint 22.1

Steps to reproduce this

Snippet:

function setup() {
  let v1 = createVector(1, 2, 3);
  let v2 = createVector(1, 2, 3, 4);
  
  // Equals is symmetric so these should print the same values, but they don't
  print(v1.equals(v2));
  print(v2.equals(v1));
}

Discussion

To be consistent with other Vector methods, equals() should log a warning if the two vectors have different lengths, then compare the components up to the smallest length.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions