Math issue
in
Programming Questions
•
9 months ago
I have a strange math issue. I'm designing a knob and I'm prototyping the code in processing. This code should make a distribution of lines starting at an given angle (-110) and end at another given angle (110), but it starts elsewhere.. Can someone here see the problem?
- void setup() {
- size(600, 500);
- background(255, 255, 255);
- float length, x1, y1, x2, y2;
- length = 20;
- float radius = 25;
- int sliderSteps = 8;
- float rotaryStartAngle = radians(-110);
- float rotaryEndAngle = radians(110);
- float theta = rotaryStartAngle;
- //distance between segments
- float angleAmount = (rotaryStartAngle + (rotaryEndAngle - rotaryStartAngle)) / sliderSteps;
- for(int i =0; i<=sliderSteps; i++){
- println(degrees(theta));
- theta += rotaryStartAngle * angleAmount;
- x1 = width/2 + cos(theta)*radius;
- y1 = height/2 + sin(theta)*radius;
- x2 = x1+cos(theta)*length;
- y2 = y1+sin(theta)*length;
- line(x1, y1, x2, y2);
- }
- }
1