# I have clock hands using trig, is it possible to make the arrows at the ends as well

#### trevor40

Hi,
First time here, and no good at all with trig, I am using a Clipsal c-bus touch screen that on a page I have created a clock with hr min and sec hands, so most of the clock is there I'd just like to add the arrows to the ends of each hand.
The code below is from the logic engine, it uses a form of Pascal for programming.

I have added code to show the hr min and sec in circles at the ends of the hands but would prefer arrows on them.
Any ideas or help is appreciated.
regards
Trevor

{Enter Constant definitions here}
ssTimeOutTimer = 1;
ssPageTimer = 2;
countdown = 1;
time1 = 1;
time2 = 1;
AfterHoursTimer = 1;
AfterHoursControlGroup = 16;
SaveAndOffGroup = 17;
WorkHoursGroup = 254;
dcCentreX = 320;
dcCentreY = 240;
dcCentreXa = 320;
dcCentreYa = 240;
dcCentreXb = 320;
dcCentreYb = 240;

{ Draw a line segment.
Angle is 0 to 59 (as in the seconds on the clock)
Length1 = distance line starts from centre
Length2 = distance line ends from centre }
procedure DrawSegment(Length1, Length2, Angle : integer);
var
ActualAngle : real;
X1, X2, Y1, Y2 : integer;
begin
ActualAngle := (angle - 15)/30 * Pi;
if Length1 = 0 then
begin
X1 := dcCentreX;
Y1 := dcCentreY;
end
else
begin
X1 := dcCentreX + round(cos(ActualAngle) * Length1);
Y1 := dcCentreY + round(sin(ActualAngle) * Length1);
end;
X2 := dcCentreX + round(cos(ActualAngle) * Length2);
Y2 := dcCentreY + round(sin(ActualAngle) * Length2);
MoveTo(X1, Y1);
LineTo(X2, Y2);
TextPos(X2-60, Y2-11);
end;

AND

if ShowingPage("CLOCK") then
begin
ClearScreen;
{ draw time markers }
{Ellipse(Left, Top, Bottom, Right);}
SetBrushStyle(1);
SetPenWidth(5);
SetPenStyle(0);
SetPenColor(clwhite);
Ellipse(85, 10, 555, 470);
SetPenColor(clblack);
SetPenWidth(3);
for dcCount := 0 to 11 do
SetBrushColor(clwhite);
SetPenColor(clwhite);
{center circle}
Ellipse(dcCentreX - 5, dcCentreY - 5, dcCentreX + 5, dcCentreY + 5);
SetPenColor(clRed);

SetPenColor(clRed);
SetPenWidth(5);
DrawSegment(0, dcClockRadius div 2, Hour * 5 + Minute div 12);
SetPenColor(clblue);
SetPenWidth(1);
SetFontSize(16);
SetPenWidth(30);
SetPenColor(clwhite);
DrawText(Second);
DrawText(Minute);
DrawSegment(100, dcClockRadius div 2, Hour * 5 + Minute div 12);

DrawText(Hour);
end;

#### trevor40

Re: I have clock hands using trig, is it possible to make the arrows at the ends as w

Hi again,
Perhaps to simplify it the code below is used to create the clock hands

ActualAngle := (angle - 15)/30 * Pi;

round(cos(ActualAngle)

this is then used in the code to draw the hands.
I was hoping there is some trig function to use this as a reference to create a line on each side of the hands at n angle relative to the hand angle.
If I can get this I can work out the rest to add it to the program.