Skip to content

Conversation

ksen0
Copy link
Member

@ksen0 ksen0 commented Oct 13, 2025

Addresses #8118 - this thread has much more detail, but the short version is as follows.

In 2.x, there are n-dimensional vectors, rather than 3D vectors, or 2D vectors that are underneath actually 3D with a 0 z-value. While this change is stabilizing, there are a couple of consequences.

First, the bug linked above: the random2D() function which uses fromAngle() should both be using 2D vectors, as they both are defined in 2D space. See the above thread for the whole discussion, but rather than a breaking change, this has been recognized as an unintentional bug.

Second, operations on vectors of non-matching sizes have to be handled. To make the whole topic more actionable, this is considered to be the scope of this issue: #8117

@ksen0 ksen0 requested a review from limzykenneth October 13, 2025 15:58
Copy link
Member

@limzykenneth limzykenneth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc is not quite correct (or at least don't match actual behavior) yet because it no longer prints p5.Vector Object : at the start but that's a separate thing to look into so this is fine as is for now.

@ksen0 ksen0 merged commit db17645 into dev-2.0 Oct 13, 2025
5 checks passed
@ksen0 ksen0 deleted the pr-8118 branch October 13, 2025 16:50
@sidwellr
Copy link

Can we please make a new issue (or sub-issue) for "operations on vectors of non-matching sizes have to be handled"? Issue #8117 is focused on eliminating the NaN in the result when subtracting a 3D vector from a 2D vector, which breaks many version 1 sketches when moved to version 2. This pull request will fix many of the problems since random2D() is a common source of the unintentional 3D vectors. But createVector() with no parameters will also create a 3D vector, which will result in NaN when subtracted from a 2D vector.

@limzykenneth
Copy link
Member

@sidwellr The dimension mismatch case we'll use #8117 to discuss and resolve.

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.

3 participants