Results 1 to 2 of 2

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

  1. #1
    Newbie
    Joined
    Jun 2019
    From
    Australia
    Posts
    2

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

    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;
    dcClockRadius = 200;
    dcCentreXa = 320;
    dcCentreYa = 240;
    dcClockRadiusa = 200;
    dcCentreXb = 320;
    dcCentreYb = 240;
    dcClockRadiusb = 200;


    { 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
    DrawSegment(dcClockRadius +15, dcClockRadius + 28, dcCount * 5);
    SetBrushColor(clwhite);
    SetPenColor(clwhite);
    {center circle}
    Ellipse(dcCentreX - 5, dcCentreY - 5, dcCentreX + 5, dcCentreY + 5);
    SetPenColor(clRed);
    DrawSegment(0, dcClockRadius, Minute);

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

    DrawText(Hour);
    end;
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Jun 2019
    From
    Australia
    Posts
    2

    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.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. clock hands
    Posted in the Algebra Forum
    Replies: 3
    Last Post: Dec 1st 2018, 12:48 AM
  2. Replies: 5
    Last Post: May 23rd 2014, 10:04 AM
  3. Hands of clock coinciding
    Posted in the Algebra Forum
    Replies: 2
    Last Post: May 22nd 2014, 09:21 AM
  4. Hands on a clock - mensuration
    Posted in the Geometry Forum
    Replies: 1
    Last Post: Apr 4th 2010, 05:33 PM
  5. Clock with transposed hands
    Posted in the Math Puzzles Forum
    Replies: 2
    Last Post: Mar 28th 2010, 11:30 PM

/mathhelpforum @mathhelpforum