Showing posts with label race track. Show all posts
Showing posts with label race track. Show all posts

Saturday, June 15, 2019

HP 42S and TI-60: Dimensions of a Race Track

HP 42S and TI-60:  Dimensions of a Race Track



We have a race track that consists of two rectangular tracks connected by a circular ring that is cut in half.  A half ring attaches to each end. 

Let the variables define the following measurements:

R0 = radius from the center of the circular ring to the outside of the track
RI = radius from the center of the circular ring to the inside of the track
C = length of the rectangular potion of the track
R0 - RI = width of the rectangular portion of the track

I am taking an imaginary line in the middle of the track (see the pink dotted line on the right side of the illustration).  The radius from the center of the ring to the pink dotted line is:
 RI + (R0 - RI)/2.

Area: 

Area
= area of the circular ring + area of the top rectangular portion + area of the bottom rectangular portion
= (π * RO^2 - π * RI^2) + C * (RO - RI) + C * (RO -RI)
= π * (RO^2 - RI^2) + 2 * C * (RO - RI)

Perimeter:

Perimeter
= circumference of the circle at the half way point between the outside and inside radius + length of the top rectangular portion + length of the bottom rectangular potion
= 2 * π * (RI + (RO - RI)/2) + C + C
= 2 * π * (RI + (RO - RI)/2) + 2 * C
= 2 * π * 1/2 * (2 *RI + RO - RI) + 2 * C
= π * (RO - RI) + 2 * C

Now that we have the calculations, let's put them to practice.

Input Variables (see above):

R0 = RO
R1 = RI
R2 = C

Ouput Variables:

R3 = area
R4 = perimeters

HP 42S/DM42/Free42 Program RACETRK

00  {68-Byte Prgm}
01  LBL "RACETRK"
02  RCL 00
03  X ↑ 2
04  RCL 01
05 X ↑ 2
06  -
07  PI
08  *
09  2 
10  RCL * 02
11  RCL 00
12  RCL - 01
13  *
14  +
15  STO 03
16  "AREA="
17  AVIEW
18  STOP
19  2
20  RCL * 02
21  RCL 01
22  RCL + 00 
23  PI
24  *
25  +
26  STO 04
27  "MID PERIMETER="
28  AVIEW
29  RTN
30  END

TI-60 Program Race Track

Format:   line number :  key code : key

00 :  91  :  π
01  :  65  :  *
02  :  53  :  (
03  : 71  : RCL
04  :  00 :  0
05  :  96  : x^2
06  :  75  :  -
07  :  71  :  RCL
08  :  01  :  1
09  :  96  :  x^2
10  :  54  :  )
11  :  85  :   +
12  :  02  :  2
13  :  65 :  *
14  :  71  :  RCL
15  :  02 :  2
16  :  65  :  *
17  :  53  :  (
18  :  71   :  RCL
19  :  00  :  0
20  :  75  :  -
21  :  71  :  RCL
22  :  01  :  1
23  :  54   :  )
24 :  95  :  =
25  :  61  :  STO
26  :  03  :  3
27  :  13   : R/S
28  :  02  :  2
29  :  65  :  *
30  :  71   :  RCL
31   :  02 :  2
32  :  85  :  +
33  :  91  :  π
34  :  65  :  *
35  :  53  :  (
36  :  71  : RCL
37  :  00  :  0
38 :  85  :  +
39  :  71  :  RCL
40  :  01 :  1
41  :  54  :  )
42  :  95  :  =
43  :  61  :  STO
44  :  04  :  4
45  :  13  : R/S
46  :  22  :  RST

Example

R0 = radius to outside ring = 12 ft
R1 = radius to inside ring = 8 ft
R2 = length of the rectangular portion of the trace = 45 ft

Results:

Area (R3) = 611.3274123 ft^2
Perimeter of the mid-line (R4) = 152.8318531 ft

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Sunday, June 3, 2018

HP Prime: At the Races


HP Prime:  At the Races

I am planning to do lots of gaming this month of June 2018.

Note: Symbols that are produced by Unicode should, but may not show up on all browsers. Please make sure your browsers are updated to the latest version.  

🐎 (Trumpet Sounds)  🐎

The program GAME_RACE simulates a race between seven racers:

Apple ѽ  (Decimal Unicode: 1149, Hexadecimal Unicode: 47D)
Knight ♞ (Decimal Unicode: 9822, Hexadecimal Unicode: 265E)
Spade ♠ (Decimal Unicode: 9824, Hexadecimal Unicode: 2660)
Club ♣ (Decimal Unicode: 9827, Hexadecimal Unicode: 2663)
Heart ♥ (Decimal Unicode: 9289, Hexadecimal Unicode: 2665)
Diamond ♦ (Decimal Unicode: 9830, Hexadecimal Unicode: 2666)
Spike ✥ (Decimal Unicode: 10021, Hexadecimal Unicode: 2725)

To watch a race in action, all you have to do is to run GAME_RACE.  Betting not included. 



🐎  HP Prime Program GAME_RACE 🐎

EXPORT GAME_RACE()
BEGIN
// 2018-04-15 EWS

// initialize racers
// apple
LOCAL l1:={1149,#FF0000h,300,30};
// knight
LOCAL l2:={9822,#C0C0C0h,300,45};
// spade
LOCAL l3:={9824,#400080h,300,60};
// club
LOCAL l4:={9827,#000080h,300,75};
// heart
LOCAL l5:={9829,#FF0000h,300,90};
// diamond
LOCAL l6:={9830,#F0E090h,300,105};
// spike
LOCAL l7:={10021,#808080h,300,120};

// the race
LOCAL h,k,j,q;

FOR h FROM 1 TO 3 DO
RECT(#00FF00h);
TEXTOUT_P(CHAR(1149)+CHAR(9822)+
CHAR(9824)+CHAR(9827)+CHAR(9829)+
CHAR(9830)+CHAR(10021),125,100,5);
TEXTOUT_P(STRING(3-h+1),125,120,5);
WAIT(1);
END;
TEXTOUT_P(" ",125,120,5,0,25,#00FF00h);
TEXTOUT_P("And they're off!",125,
120,5);
WAIT(0.5);

REPEAT

// background
RECT();

// background
FILLPOLY_P({(20,0),(20,150),
(330,150),(330,0)},#00FF00h);
FILLPOLY_P({(0,0),(0,150),
(20,150),(20,0)},#E0E0E0h);
LINE_P(0,25,330,25);
// crowd
FOR h FROM 20 TO 300 STEP 10 DO
TEXTOUT_P(CHAR(9823),h,0,5);
END;
TEXTOUT_P(CHAR(9818),140,0,5,#000080h);
TEXTOUT_P(CHAR(9819),150,0,5,#FF0000h);
// racers
FOR h FROM 1 TO 7 DO
TEXTOUT_P(CHAR(1149),l1(3),l1(4),5,l1(2));
TEXTOUT_P(CHAR(9822),l2(3),l2(4),5,l2(2));
TEXTOUT_P(CHAR(9824),l3(3),l3(4),5,l3(2));
TEXTOUT_P(CHAR(9827),l4(3),l4(4),5,l4(2));
TEXTOUT_P(CHAR(9829),l5(3),l5(4),5,l5(2));
TEXTOUT_P(CHAR(9830),l6(3),l6(4),5,l6(2));
TEXTOUT_P(CHAR(10021),l7(3),l7(4),5,l7(2));
END;

WAIT(0.5);
// move the racers
l1(3):=l1(3)-RANDINT(1,3)*5;
l2(3):=l2(3)-RANDINT(1,3)*5;
l3(3):=l3(3)-RANDINT(1,3)*5;
l4(3):=l4(3)-RANDINT(1,3)*5;
l5(3):=l5(3)-RANDINT(1,3)*5;
l6(3):=l6(3)-RANDINT(1,3)*5;
l7(3):=l7(3)-RANDINT(1,3)*5;


q:={l1(3),l2(3),l3(3),
l4(3),l5(3),l6(3),l7(3)};
q:=q<5;
q:=ΣLIST(q);
UNTIL q>0;

TEXTOUT_P("The race is over!",
0,160,5,#008000h);

WAIT(0);
END;

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Symmetric Quartic Equation - Python

Symmetric Quartic Equation - Python Note: The code is programmed with a TI-84 Evo. No modules are used, so the scripts should be adopt...