[p5.js 2.0+ Bug Report]: Vector.slerp() does not work correctly for vectors of more than three dimensions
メンテナーはふだん 2 日以内に返信
@Aman-goel-04 がすでに取り組んでいます。
2026年7月25日 から。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- javascript
調査の方向性
Issue に記載されているインスタンスおよび static の p5.Vector.slerp() エントリーポイントから始め、続いて提供された 4D の例を再現します。現在の cross() ベースの動作を、提案されている一般的な slerp の式と比較し、その際に 2D および 3D の結果が変わらないことを確認します。4D 補間が期待されるベクトルを生成し、既存の低次元の動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
Steps:
- Create two 4D vectors
- Use slerp() to interpolate between the two
- Note the result is incorrect
Snippet:
function setup() {
let c = 0.5;
let v1 = createVector(0, 1, 0, 1);
let v2 = createVector(1, 0, 1, 0);
v1.slerp(v2, 0.5);
// v1 should be vector[0.707, 0.707, 0.707, 0.707] but is actually vector[0.5, 0.707, 0.5, 1]
print(v1.toString());
}
Discussion
slerp() currently uses cross() for its computation, which is only defined for 3D vectors. It needs to use a more general formula, which is readily available on the web; search for "slerp formula".
Feel free to adapt the following (to both the instance and static methods). In my brief testing, it gives the same result as the current slerp() for 2D and 3D vectors, and also seems to work correctly for 4D vectors. It can certainly be optimized.
function slerp(v0, v1, t) {
let m = v0.mag() + (v1.mag() - v0.mag()) * t;
let r0 = p5.Vector.normalize(v0);
let r1 = p5.Vector.normalize(v1);
let a = acos(r0.dot(r1));
if (a === 0) {
return p5.Vector.add(v0, p5.Vector.sub(v1, v0).mult(t));
} else {
r0.mult(sin((1 - t) * a) / sin(a));
r1.mult(sin(t * a) / sin(a));
return r0.add(r1).mult(m);
}
}
- 主要言語
- JavaScript
- スター
- 24.1k
- フォーク
- 3.9k
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 29
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
processing/p5.js のほかの issue
-
Add unit tests for noiseDetail()対応中かも @harshiltewari2004 が 1 日前に担当しました。 オープンArea:Math Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
processing/p5.js#9253 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
[p5.js 2.0+ Bug Report]: storeItem() validation branches are missing `return`, so bad input throws a TypeError or is stored anyway対応中かも @iUjjwalRaj が 9 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
processing/p5.js#9242 ·
メンテナーはふだん 2 日以内に返信
-
[p5.js 2.0+ Bug Report]: getURLParams() mis-parses valueless parameters and never percent-decodes values対応中かも @mayanksingh-7974 が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
processing/p5.js#9241 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[p5.js 2.0+ Bug Report]: Typo in Spanish reference documentation for ellipseMode()再び着手できるかも @cgutierrezval が 12 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンInternationalization p5.js 2.0+
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
processing/p5.js#9231 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
[p5.js 2.0+ Bug Report]: ReferenceError: p5 is not defined when calling loadPixels/get/copy/mask on p5.MediaElement in ESM対応中かも @Pcmhacker-piro が 17 日前に担当しました。 オープンArea:Core Area:DOM
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
processing/p5.js#9189 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
processing/p5.js の issue をすべて見る
似ている issue
-
Four problem loader browser tests fail on Windows対応中かも @Patriciaath999 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
juice-shop/juice-shop#3686 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ScottKirvan/GOMAC#56 ·
-
area:install bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
yetone/magpie#2406 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信