Hi, I’m Charmaine and am currently taking Dan and Su’s fundamental’s class. My partner and I are having trouble with a processing sketch. Please refer to the link.

We’re trying to generate a triangle, from an origin and known coordinates (`mousePressed`

), that keeps two fixed lengths constant (Left and Bottom side).

Questions:

- How do we get the left side to stay constant?
- Why is
`println(degrees(aA));`

displaying incorrect numbers?

The goal is to have the triangle to work so that we can calculate the (Left and Bottom angle), which will be sent to the arduino to control servo motors.

```
float a, b, c;
float aA, aB, aC;
float cosA, cosB, cosC;
PVector va, vb, vc;
float angle;
float tempA, tempO;
void setup() {
size(900, 600);
va = new PVector(-450, 0);
vb = new PVector(150, -10);
vc = new PVector(0, 0);
a = 250;
b = 250;
println(degrees(angle));
}
void draw() {
background(0);
translate(width/2, height);
if (mousePressed == true) {
vb.set(mouseX-width/2, mouseY-height, 0);
angle = degrees(PVector.angleBetween(va, vb));
tempO = abs(sin(angle-aA))*a;
tempA = abs(cos(angle-aA))*a;
vc.set(-1*tempA, -1 *tempO, 0);
stroke(255);
line(va.x+450, va.y, vb.x, vb.y);
c = dist(va.x+450, va.y, vb.x, vb.y);// now we know the length of all sides
cosA = (b*b+c*c -a*a)/2/b/c;
aA = acos(cosA);
aB = aA;
aB = 180 - aA*2;
println(degrees(aA));// angle for servo #1
}
triangle(va.x+450, va.y, vb.x, vb.y, vc.x, vc.y);
}
```

Please let me know if I am being unclear. Thank you!