Skip to content

Commit

Permalink
Merge pull request #481 from heyarne/bugfix/improve-polar-cartesian-docs
Browse files Browse the repository at this point in the history
docs: use same parameter names as in doc string
  • Loading branch information
postspectacular authored Jul 16, 2024
2 parents ba4f2cd + 931ec90 commit 70460a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions packages/vectors/src/cartesian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const cartesian: MultiVecOpVO<ReadonlyVec> = vop(1);
* @param v -
* @param offset -
*/
export const cartesian2 = cartesian.add(2, (out, a, b = ZERO2) =>
add2(out || a, cossin(a[1], a[0]), b)
export const cartesian2 = cartesian.add(2, (out, v, offset = ZERO2) =>
add2(out || v, cossin(v[1], v[0]), offset)
);

/**
Expand All @@ -40,15 +40,15 @@ export const cartesian2 = cartesian.add(2, (out, a, b = ZERO2) =>
* @param v -
* @param offset -
*/
export const cartesian3 = cartesian.add(3, (out, a, b = ZERO3) => {
const r = a[0];
const theta = a[1];
const phi = a[2];
export const cartesian3 = cartesian.add(3, (out, v, offset = ZERO3) => {
const r = v[0];
const theta = v[1];
const phi = v[2];
const ct = cos(theta);
return setC3(
out || a,
r * ct * cos(phi) + b[0],
r * ct * sin(phi) + b[1],
r * sin(theta) + b[2]
out || v,
r * ct * cos(phi) + offset[0],
r * ct * sin(phi) + offset[1],
r * sin(theta) + offset[2]
);
});
16 changes: 8 additions & 8 deletions packages/vectors/src/polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const polar: MultiVecOpV = vop(1);
* @param out -
* @param v -
*/
export const polar2 = polar.add(2, (out, a) =>
setC2(out || a, mag(a), atan2(a[1], a[0]))
export const polar2 = polar.add(2, (out, v) =>
setC2(out || v, mag(v), atan2(v[1], v[0]))
);

/**
Expand All @@ -36,12 +36,12 @@ export const polar2 = polar.add(2, (out, a) =>
* @param out -
* @param v -
*/
export const polar3 = polar.add(3, (out, a) => {
const x = a[0];
const y = a[1];
const z = a[2];
export const polar3 = polar.add(3, (out, v) => {
const x = v[0];
const y = v[1];
const z = v[2];
const r = sqrt(x * x + y * y + z * z);
return r > 0
? setC3(out || a, r, asin(z / r), atan2(y, x))
: setC3(out || a, 0, 0, 0);
? setC3(out || v, r, asin(z / r), atan2(y, x))
: setC3(out || v, 0, 0, 0);
});

0 comments on commit 70460a3

Please sign in to comment.