+ 2

Corner Algorithm

Does anyone know an algorithm to loop through a corners of a polygon? https://code.sololearn.com/WgEhP6AzzLBw/?ref=app

20th Jul 2019, 10:55 AM
Clueless Coder
Clueless Coder - avatar
2 odpowiedzi
+ 2
I don't really get your question, since you kind of already made it in the fifth line. You could use a function like this (If you would use classes, please use classes, classes are very good, I promise): corner(i) { return [this.x + cos(i * this.angle) * this.r, this.y + sin(i * this.angle) * this.r]; } (I didn't look at your code that much, but it basically returns an array of the x and y position of the angle, please look at it, don't just copy and paste it it probably wouldn't work)
20th Jul 2019, 11:30 AM
Airree
Airree - avatar
0
I get what you are saying. Thanks for the reply. I used to use classes but I they take ages to build (especially with a lot of them) and they reduce readability. I use constructor functions. I implemented what you did without the use of classes. Thanks for the help. Trigonmetry brings out the worst of my ability!
20th Jul 2019, 11:41 AM
Clueless Coder
Clueless Coder - avatar