Skip to content

Commit

Permalink
Fix typo in vec2.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
baku89 committed Feb 24, 2024
1 parent f091610 commit b18d0e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/vec2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,31 +125,31 @@ test('rotate', () => {
})

describe('angle', () => {
it('shoud work in the case of 0°', () => {
it('should work in the case of 0°', () => {
expect(vec2.angle([1, 0])).toEqual(0)
})

it('shoud returns 0° for same vectors', () => {
it('should returns 0° for same vectors', () => {
expect(vec2.angle([1, 2], [1, 2])).toEqual(0)
})

it('shoud returns 0° for collinear vectors', () => {
it('should returns 0° for collinear vectors', () => {
expect(vec2.angle([1, 2], [3, 6])).toEqual(0)
})

it('shoud returns 0° for zero vector', () => {
it('should returns 0° for zero vector', () => {
expect(vec2.angle([0, 0])).toEqual(0)
})

it('shoud returns 0° for vectors one of whom is zero', () => {
it('should returns 0° for vectors one of whom is zero', () => {
expect(vec2.angle([0, 0], [1, 0])).toEqual(0)
})

it('shoud returns 0° for vectors one of whom is zero', () => {
it('should returns 0° for vectors one of whom is zero', () => {
expect(vec2.angle([3, 4], [0, 0])).toEqual(0)
})

it('shoud work in the case of 90°', () => {
it('should work in the case of 90°', () => {
expect(vec2.angle([0, 1])).toEqual(90)
})

Expand Down
4 changes: 2 additions & 2 deletions src/vec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ export namespace vec2 {
if (!b) return Math.atan2(a[1], a[0]) * Common.RAD2DEG

if (eq(a, b)) {
// Exactly vectors
// Exactly the same vectors
return 0
}

Expand All @@ -595,8 +595,8 @@ export namespace vec2 {
}

const sign = x1 * y2 - y1 * x2 >= 0 ? 1 : -1
const acos = Math.acos(scalar.clamp(dot(a, b), -1, 1) / mag)

const acos = Math.acos(scalar.clamp(dot(a, b) / mag, -1, 1))
const angle = sign * acos * Common.RAD2DEG

return angle <= -180 ? angle + 360 : angle
Expand Down

0 comments on commit b18d0e0

Please sign in to comment.