Skip to content

Commit

Permalink
chore(example): update example and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Apr 11, 2019
1 parent e704c0c commit 1e22cce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ Internally the `valueOf()` implementation returns `x` in first call, `y` in seco

[![code preview](https://us-central1-code-snippet-to-svg.cloudfunctions.net/default/basics/vector/blob/master/examples/example.js?theme=atom_one_light&range=42-48)](https://github.com/basics/vector/blob/master/examples/example.js)

### normalize only with arithmetic

[![code preview](https://us-central1-code-snippet-to-svg.cloudfunctions.net/default/basics/vector/blob/master/examples/example.js?theme=atom_one_light&range=58-63)](https://github.com/basics/vector/blob/master/examples/example.js)

## immutable vector called Victor

behaves exactly like Vector but code cant change its `x`, `y` and `z` axes.
Expand Down
5 changes: 5 additions & 0 deletions examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ try {
// error: Error: set x() not implemented
}

// normalize only with arithmetic
const norm = calc(() => offsetA / offsetA.length);
console.log(debug`norm: ${norm}`);
// norm: { x: 0.967, y: 0.1658, z: 0.1934 }

// creating vector inside calculation works, but has overhead
const inlineVec = new Victor(() => new Victor(25, 30) / 2);
console.log(debug`inlineVec: ${inlineVec}`);
Expand Down

0 comments on commit 1e22cce

Please sign in to comment.