 # how do you make triangle base pivot

Using UTFT and UTFT_geometry library

I'm using a variation of HazardMinds post from another thread. But he was using drawLine.

The pointer side works fine. My problem is I can't get the base of the triangle to pivot

``````}

double mD(double data, double in_min, double in_max, double out_min, double out_max)//Map double
{
return (data - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

void drawNeedle(int sensor,int pos_x, int pos_y){
double cur = mD(analogRead(A0),0,1023,0,(1.5 * pi));
x = pos_x + cos(cur + (pi/2)) * rad;
y = pos_y + sin(cur + (pi/2)) * rad;

trx = pos_x - 5;
tr = pos_y;
tlx =  pos_x + 5;
tl = pos_y;
topx = x;
top = y;

if(topx != otopx && top != otop)
{
myGLCD.setColor(BLACK);
geo.fillTriangle(otrx, otr, otlx, otl, otopx, otop);
myGLCD.setColor(RED);
geo.fillTriangle(trx, tr, tlx, tl, topx, top);

otrx = trx;
otr = tr;
otlx = tlx;
otl = tl;
otopx = topx;
otop = top;

void loop(){

drawNeedle(A0,120,170);

}

void loop(){

drawNeedle(A0,120,170)
}
``````

This does the same thing.

``````void drawNeedle(int sensor,int pos_x, int pos_y, int pos_x2, int pos_y2){
double cur = mD(analogRead(A0),0,1023,0,(1.5 * pi));
x = ((pos_x + pos_x2)/2) + cos(cur + (pi/2)) * rad;
y = ((pos_y + pos_y2)/2) + sin(cur + (pi/2)) * rad;

trx = pos_x + cos(cur + (pi/2)) * 10;
tr = pos_y + sin(cur + (pi/2)) * 10;
tlx = pos_x2 + cos(cur + (pi/2)) * 10;
tl = pos_y2 + sin(cur + (pi/2)) * 10;
topx = x;
top = y;

drawNeedle(A0,120,170,125,170);
``````