Skip to content

Instantly share code, notes, and snippets.

@Reine0017
Created April 10, 2021 06:54
Show Gist options
  • Select an option

  • Save Reine0017/e2fdb4edb07247f314cb5191bc427bce to your computer and use it in GitHub Desktop.

Select an option

Save Reine0017/e2fdb4edb07247f314cb5191bc427bce to your computer and use it in GitHub Desktop.
Calculate and Create Coordinate Arrays for Helix
//Note that this isn't the full code for this js file, please refer to the repo for the full code
const linspaceFn = (startValue, stopValue, cardinality) => {
var arr = [];
var step = (stopValue - startValue) / (cardinality - 1);
for (var i = 0; i < cardinality; i++) {
arr.push(parseFloat((startValue + (step * i)).toFixed(3)));
}
return arr;
}
const t = linspaceFn(0, 20, 100)
const x = t.map(i => (Math.cos(i)))
const y = t.map(i => Math.sin(i))
const z = t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment