URL of experiment:

Description of the problem:

Hello,

I am trying to code an experiment where I have 2 aligned dots (creating an imaginary line), and with the left/right arrow key I want to move them to control their imaginary orientation line.

In real time, I want to modify the positions of 2 dots by pressing left/right arrow keys.

I managed to make it work, but the rotation is VERY slow.

Any idea on how to speed up this?

This is what I did:

**Routine:** N_p_Resp

**Begin Experiment:**

```
xStart = 0;
yStart = 0;
xStart2 = 0;
yStart2 = 0;
Dot1 = new visual.Polygon ({
win: psychoJS.window, name: 'Dot1', units : 'height',
edges: 99, size:[0.05, 0.05],
ori: 0, pos: [xStart, yStart],
lineWidth: 1, lineColor: new util.Color([1, 1, 1]),
fillColor: new util.Color([1, 1, 1]),
opacity: 1, depth: -5, interpolate: true,
});
Dot2 = new visual.Polygon ({
win: psychoJS.window, name: 'Dot2', units : 'height',
edges: 99, size:[0.05, 0.05],
ori: 0, pos: [xStart2, yStart2],
lineWidth: 1, lineColor: new util.Color([1, 0, 0]),
fillColor: new util.Color([1, 0, 0]),
opacity: 1, depth: -5, interpolate: true,
});
```

**Begin Routine:**

```
BarOrientation = Math.floor(Math.random() * 360 - 0);
BarOrientation2 = BarOrientation+180;
// bar_p_3.setOri((- BarOrientation));
error = GabOrPractice2 - BarOrientation;
ErrorMessage = "Stripe Orientation=" + (GabOrPractice2) + "° Bar Orientation=" + BarOrientation + "° Error=" + error + "°\n Hit space when you're done";
radiusDeg = .1
angleR = BarOrientation * (Math.PI/180);
line1Response = angleR;
xStart = Math.sin(angleR) * radiusDeg;
yStart = Math.cos(angleR) * radiusDeg;
angleR2 = BarOrientation2 * (Math.PI/180);
line1Response2 = angleR2;
xStart2 = Math.sin(angleR2) * radiusDeg;
yStart2 = Math.cos(angleR2) * radiusDeg;
Dot1.setAutoDraw(true);
Dot2.setAutoDraw(true);
```

**Each Frame:**

```
if(BarOrientation > 359) {
BarOrientation -= 360;
}
if(BarOrientation2 > 359) {
BarOrientation2 -= 360;
}
angleR = BarOrientation * (Math.PI/180);
xStart = Math.sin(angleR) * radiusDeg
yStart = Math.cos(angleR) * radiusDeg
angleR2 = BarOrientation2 * (Math.PI/180);
xStart2 = Math.sin(angleR2) * radiusDeg
yStart2 = Math.cos(angleR2) * radiusDeg
Dot1.setPos([(xStart), yStart]);
Dot1.setAutoDraw(true);
Dot2.setPos([(xStart2), yStart2]);
Dot2.setAutoDraw(true);
```

**End Routine:**

```
Dot1.setAutoDraw(false);
Dot2.setAutoDraw(false);
```