The code is mostly taken from Victor.js. I am currently adding Typescript type definitions and tests.
This are changes already implemented:
rotateBy
and rotateByDeg
which seemed to be broken or not useful (Issue agreeing with that)rotate
and rotateDeg
to rotateBy
and rotateByDeg
which make more sense.random()
function. For some reason it generated a number between min
and max + 1
which sounded confusing..toFixed()
converted components to string, fixed to keep them number, might renamed the function as suggested here: https://github.com/maxkueng/victor/issues/28resize()
(Victor #39 but with a ~10x faster implementation than the proposed code)rotateTowards
/rotateTowardsDeg
to steer a vector toward another one.fromArray
and .fromObject
to explicitly fail on invalid input but also accept string representations instead of numbers.clamp
to clamp the magnitude and clampX
, clampY
to clamp the axes.fromPolar
and toPolar
methods.limitX
and limitY
to go with limit
toFixed
to fixPrecision
to avoid confusion with Number.toFixed
and the fact that it casts numbers to strings.Things I want to review before considering the library ready to be officially published:
~Rework categories (split angle and rotation)~
~Rename rotate
by rotateBy
~
~Add rotateToward(vec, maxAngle)
~
~Maybe add resize = normalize + multiplyScalar~
~Maybe add fromPolar
https://github.com/maxkueng/victor/issues/26`~
~Maybe isPerpendicular
, isParallel
https://github.com/maxkueng/victor/pull/42~
~Implement limitX
and limitY
and use them in limit
.~
~Implement clamp(max: number, min?: number)
: Always apply mag = Math.max(mag, max)
and if min
is defined mag = Math.min(mag, min)
(handle special case for mag === 0
. max
and min
must always be positive. Also implement clampX
and clampY
.~
~Maybe integrate the code from this issue. After testing I realized the proposed function computes the angle between the vector created between the 2 input vectors and the x axis. The name proposed in the issue needs to change.~ Won't do I would make more sense to use vec1.subtract(v2).angle()
.
In the README add a word about immutability https://github.com/maxkueng/victor/issues/18
Add an epsilon
property to Vector
to improve computations stability?
Use spellcheck to avoid typos.
Find a way to validate docs (make sure all required tags are used, maybe make sure the documented method is used in the @example
tag)
Create a dedicated section for dev workflow documentation.
Rework publishing
simplevector
when we are ready.main
branch.~Using latest node features to run typescript and tests so
No tsconfig.json
because node 24+ handles typescript
We replaced the usage of jest
and chai
of Victor with nodeJS built-in test runner and assertions.
When cloning the repo ln -s "$(pwd)/tools/pre-commit" .git/hooks/pre-commit
to enable local formatting and linting on commit.
The Github CI handle the publication of the package to npm and the deployment of the github pages for the docs website. See .github/workflows/publish-npm.yml
.
Update the version
field in package.json
to trigger the publishing of a new version and its documentation.