Skip to content

Commit

Permalink
Remove subP on vector
Browse files Browse the repository at this point in the history
  • Loading branch information
yzrmn committed Aug 26, 2024
1 parent 6116af7 commit 3388e8e
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions packages/redgeometry/src/primitives/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ export class Vector2 implements Vector2Like {
}

/**
* Adds the current vector to a point `p`.
* Returns the sum of the current vector and a point `p`.
*/
public addP(p: Point2): Point2 {
// This is provided as syntactic sugar for e.g. Horner's method
// `qa.mulS(t).add(qb).mulS(t).addP(qc)`
// where `qa` and `qb` are vectors and `qc` is a point
return p.addV(this);
}

Expand Down Expand Up @@ -238,13 +241,6 @@ export class Vector2 implements Vector2Like {
return new Vector2(this.x - v.x, this.y - v.y);
}

/**
* Substracts the current vector from a point `p`.
*/
public subP(p: Point2): Point2 {
return p.subV(this);
}

public toArray(): [number, number] {
return [this.x, this.y];
}
Expand Down Expand Up @@ -355,22 +351,25 @@ export class Vector3 implements Vector3Like {
}

/**
* Adds the current vector to a point `p`.
* Returns the sum of the current vector and a point `p`.
*/
public addP(p: Point3): Point3 {
// This is provided as syntactic sugar for e.g. Horner's method
// `qa.mulS(t).add(qb).mulS(t).addP(qc)`
// where `qa` and `qb` are vectors and `qc` is a point
return p.addV(this);
}

/**
* Returns the angle between the current vector and `v` in radians.
* Returns the angle between the current vector and a vector `v` in radians.
*
* Note: The returned value is unsigned and less than or equal to `PI`.
*/
public angleTo(v: Vector3): number {
const a = this.lenSq() * v.lenSq();

if (a === 0) {
// Return an angle of zero if one vector is zero
// Return an angle of zero if any vector is zero
return 0;
}

Expand Down Expand Up @@ -539,13 +538,6 @@ export class Vector3 implements Vector3Like {
return new Vector3(this.x - v.x, this.y - v.y, this.z - v.z);
}

/**
* Substracts the current vector from a point `p`.
*/
public subP(p: Point3): Point3 {
return p.subV(this);
}

public toArray(): [number, number, number] {
return [this.x, this.y, this.z];
}
Expand Down

0 comments on commit 3388e8e

Please sign in to comment.