Skip to content

Instantly share code, notes, and snippets.

@anuraghazra
Last active May 16, 2019 12:58
Show Gist options
  • Save anuraghazra/cfcf10a184d21d076c03b3cd9d7d281e to your computer and use it in GitHub Desktop.
Save anuraghazra/cfcf10a184d21d076c03b3cd9d7d281e to your computer and use it in GitHub Desktop.
class Stick {
constructor(p1, p2, length) {
this.startPoint = p1;
this.endPoint = p2;
this.stiffness = 2;
this.color = '#f5476a';
// if the length is not given then calculate the distance based on position
if (!length) {
this.length = this.startPoint.pos.dist(this.endPoint.pos);
} else {
this.length = length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment