Showing posts with label circles. Show all posts
Showing posts with label circles. Show all posts

Monday, July 11, 2022

TI-58/TI-59 Week: ML 13 Curve Solution

 TI-58/TI-59 Week:  ML 13 Curve Solution


Introduction


Today's blog entry highlights just one of the wonderful programs offered by Texas Instrument's Master Library.  


When the Master Library ROM program module is in the TI-58, TI-58C (for this week I will say the TI-58 to refer to both the TI-58 and TI-58C), and the TI-59, call up the Curve Solution by pressing [ 2nd ] [ LRN ] (Pgm) 13.  


The user keys are assigned as:


A:  enter the central angle in radians ( θ )

B:  enter the circle's radius ( r )

C:  enter the arc length ( s )

D:  enter the chord length ( c )

E:  solve for the sector area ( A' )


A':  solve for the central angle ( θ' )

B':  solve for the radius ( r' )

C':  solve for arc length ( s' )

D':  solve for the chord length ( c' )

E':  solve for segment area ( a' )


Enter two of the variables θ, r, s, and c and solve for the rest, and at least one of the two variables θ or r must be entered.  


Examples


Example 1:  Known: r and c


r = 10.8

c = 12.0


[ 2nd ] (Pgm) 13

10.8 [ B ]  ( r )

12.0 [ D ]  ( c )

[ 2nd ] (A'):  1.17806194 rad  ( θ )

[ 2nd ] (C'):  12.72306896  (arc length)

[ E ]:  68.70457237 (sector area)

[ 2nd ] (E'):  14.824706 (segment area)


Example 2:  Known: θ and s


[ 2nd ] (Pgm) 13 

30° angle:   30 [ ÷ ] 180 [ × ] [ 2nd ]  ( π ) [ = ] [ A ]   ( θ )

40 [ C ]  ( s )

[ 2nd ] ( B' ):  76.39437268 ( r )

[ 2nd ] ( D' ): 39.54463718 ( c )

[ E ]:  1527.887454 (sector area)

[ 2nd ] (E'):  68.86240923 (segment area)


A little detour from our usually programming the calculator ourselves, but it is sometimes more effective and efficient to take advantage of either advanced built in or mainstream modules.  Alas, we do return to programming next time,


Eddie 


All original content copyright, © 2011-2022.  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. 


Saturday, October 24, 2020

HP 42S/DM42/Free42: Drawing Lines and Circles

 HP 42S/DM42/Free42:  Drawing Lines and Circles



Introduction

The HP 42S, Swiss Micros DM42, and Free42 has several graphics commands that allows for drawing and plotting functions.   The following programs draw simple geometric objects on the calculator's screen:

HLINE:  horizontal line

VLINE:  vertical line

DLINE:  a line between two points

DCIRC:  draw a circle given a center point and radius


The graphics screen of the 42S is 131 x 16.  The x axis goes from 1 to 131 to the right, while the y axis goes from 1 to 16 down.  


To plot points along the line, use the equation:

y = slope * x + (y1 - x1 * slope)

where slope = (y1 - y0) / (x1 - x0)


For the circle, the pixels to be plotted are:

x' = x + r * sin θ

y' = x + r * cos θ

for θ from 0° to 360°  (0 to 2π in radians)


Since a full circle is plotted, we don't have to worry about accounting for the fact that the y axis is inverted.  


Commands used:


CLLCD:  clear the screen


PRLCD:  print the screen.  Depending on whether the printer is on or off and what machine is being used, the screen would printed to the optional infrared printer or saved as a print file.  Turning print off (by the PROFF setting) will just display the screen.  


PIXEL:  Takes the arguments from the y-stack and x-stack and draws a pixel.   There are several flags that can affect how the command operates, that is beyond the scope of this blog entry.  Non-integer numbers can be used as pixels.


HP 42S/DM42/Free42 Program:  HLINE


     00 { 58-Byte Prgm }

          01 LBL "HLINE"

           02 "X START?"

             03 PROMPT  

             04 STO 01  

             05 "X END?"

             06 PROMPT  

             07 STO 02  

             08 "Y?"    

             09 PROMPT  

             10 STO 03  

             11 RCL 02  

             12 1ᴇ3     

             13 ÷       

             14 RCL+ 01 

             15 STO 00  

             16 CLLCD   

             17 LBL 01  

             18 RCL 03  

             19 RCL 00  

             20 IP      

             21 PIXEL   

             22 ISG 00  

             23 GTO 01  

             24 PRLCD   

             25 END 


HP 42S/DM42/Free42 Program:  VLINE


    00 { 58-Byte Prgm }

          01 LBL "VLINE"

             02 "X?"    

             03 PROMPT  

             04 STO 03  

           05 "Y START?"

             06 PROMPT  

             07 STO 01  

             08 "Y END?"

             09 PROMPT  

             10 STO 02  

             11 RCL 02  

             12 1ᴇ3     

             13 ÷       

             14 RCL+ 01 

             15 STO 00  

             16 CLLCD   

             17 LBL 01  

             18 RCL 00  

             19 IP      

             20 RCL 03  

             21 PIXEL   

             22 ISG 00  

             23 GTO 01  

             24 PRLCD   

             25 END  


HP 42S/DM42/Free42 Program:  DLINE


The x coordinates are entered first.  The point (x0, y0) is the to left of the point (x1, y1) and x0 < x1 is required.  Attempt to draw vertical lines where x0 = x1 using DLINE will result in an error.


 00 { 89-Byte Prgm }

          01 LBL "DLINE"

            02 "X0 < X1"

             03 AVIEW   

             04 STOP    

             05 "X0?"   

             06 PROMPT  

             07 STO 01  

             08 "X1?"   

             09 PROMPT  

             10 STO 03  

             11 1ᴇ3     

             12 ÷       

             13 RCL+ 01 

             14 STO 00  

             15 "Y0?"   

             16 PROMPT  

             17 STO 02  

             18 "Y1?"   

             19 PROMPT  

             20 STO 04  

             21 X<>Y    

             22 -       

             23 RCL 03  

             24 RCL- 01 

             25 ÷       

             26 STO 05  

             27 RCL× 03 

             28 +/-     

             29 RCL+ 04 

             30 STO 06  

             31 CLLCD   

             32 LBL 01  

             33 RCL 00  

             34 IP      

             35 RCL× 05 

             36 RCL+ 06 

             37 RCL 00  

             38 IP      

             39 PIXEL   

             40 ISG 00  

             41 GTO 01  

             42 PRLCD   

             43 END     


HP 42S/DM42/Free42 Program:  DCIRC


 00 { 70-Byte Prgm }

          01 LBL "DCIRC"

             02 "X CTR?"

             03 PROMPT  

             04 STO 01  

             05 "Y CTR?"

             06 PROMPT  

             07 STO 02  

            08 "RADIUS?"

             09 PROMPT  

             10 STO 03  

             11 DEG     

             12 0.36005 

             13 STO 00  

             14 CLLCD   

             15 LBL 01  

             16 RCL 00  

             17 IP      

             18 RCL 03  

             19 →REC    

             20 RCL+ 01 

             21 X<>Y    

             22 RCL+ 02 

             23 X<>Y    

             24 PIXEL   

             25 ISG 00  

             26 GTO 01  

             27 PRLCD   

             28 .END.   


These programs and routines can be used stand-alone or as subroutines.  


You can download the four programs here:  

https://drive.google.com/file/d/1FJqVTkGMAtLa-0eMBHQ1LEfdKGt55VNM/view?usp=sharing


Eddie


All original content copyright, © 2011-2020.  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. 


Thursday, November 5, 2015

HP Prime Geometry App Tutorial Part 1: Circles

HP Prime Geometry App Tutorial Part 1:  Circles

This tutorial series will focus on the HP Prime’s Geometry App.  Most of the time we will focus on the Plot screen.  The software version that we are working with is Build 8151 (6/17/2015).

Setting Up the Plot Screen

For the tutorial, I am going to set the plot screen with the following parameters:  XRange = [-16, 16], YRange = [-11, 10.9], and the ticks for both axes are 1.


Steps:

1.  Press [ Shift ], [ Plot ] (Plot Setup).
2.  Set up the parameters as shown below.  Note that the Xmax and Ymax are automatically set.  I also recommend that you set the calculator to Degrees mode through the Settings Menu.



For this lesson, we are going to draw a circle, draw its radius, find its circumference, and its area.

Draw a Circle

1. Press [ Plot ] to go the plot screen.  If necessary, clear the workspace by pressing [ Shift ], [ Esc ] (Clear). 
2.  Press the soft menu key (Cmds), select 5 for Curve, 1 for Circle.  You are prompted to determine where the center of the circle.  
3. For this lesson, just move the cursor, or click on/touch the screen anywhere you like.  Press [ Enter ] to anchor the circle’s center.
4.  Select a point to determine who far the circle expands.  Pressing [ Enter ] will draw the circle, and plot the point you selected on the circle’s edge.



Note how everything is labeled.  A is the center, B is the outer point, and C is the circle.  If you were to refer to these objects outside of the plot screen (like the Num screen or the CAS Home screen), you will need to have a G (capital “G”) suffix attached, like this: GA, GB, GC. 

Draw the Radius of a Circle

1.  Go to the center of the circle (point A).  You can scroll your cursor by using the arrow keys or touch on/click on the screen.  As of the current version (8151), there is no “Go To” feature (hopefully on a future update).
2.  Press (Cmds), 3 for Line, 1 for Segment.  Select the center by pressing [ Enter ].
3.  Select any of the circle’s edge and press [ Enter ].  The radius, represented by the line segment is drawn.


Measuring the Circle’s Radius (the easy way)

1.  Press (Cmds), 9 for Measurement, 2 for Radius.
2.  Select the circle.  When the circle is selected when it turns red.  Press [ Enter ].
3.  The result will be on top of the Plot screen.




Measuring the Circle’s Area

1.  Press (Cmds), 9 for Measurement, 5 for Area.
2.  Like the last exercise, select the circle.  Again, you know if the circle is selected (by the cursor’s placement) if the circle is red.  Press [ Enter ].
3.  The circle will filled with color and the result will be on top of the Plot screen.



That is going to wrap up Part 1 of the HP Prime Geometry App Tutorial.  In Part 2, we’ll be working with Triangles, finding angles, re-sizing, and reflecting triangles.  Until then, have a great day!

Eddie



This blog is property of Edward Shore.  2015. 


Thursday, May 7, 2015

TI 84 Color Programs: Circles, Arc Length, Area Between Curves

TI 84 Color Programs

For this blog entry, I used TI Connect CE to transfer the programs and get screen shots.  It is sweet!  TI Connect CE works with the TI-84 Plus family (Monochrome, C Silver Edition, and the upcoming CE (review coming soon!)).  You can edit programs and transfer them.  The interface is a lot nicer, and you can drag and drop programs and data files. 

This blog will feature some of the color functions and commands of the TI 84 Plus C Silver Edition (and the upcoming TI 84 Plus CE). 

CIRCLE4 in Progress


CIRCLE4:  Circle Draw and Update Program

Notes:
*  Press 1, 2, 3, and 4 to change the color of the circles.  The colors cycle through black, blue, red, and green.
*  Since a list is used, we must use the numeric color identifiers: 12 for black, 10 for blue, 11 for red, and 14 for Green. (see table below for full reference)
* Database is stored and recalled to preserve the current database (0).

Numeric Color Identifiers:
10:  blue
11:  red
12:  black
13:  magenta
14:  green
15:  orange
16:  brown
17:  navy
18:  light blue
19:  yellow
20:  white
21:  light gray
22:  medium gray
23:  gray
24:  dark gray

Program:
StoreGDB 0:0→J
AxesOff:FnOff
ZStandard:ClrDraw
{12,10,11,14}→L
{1,1,1,1}→L
Goto 0
Lbl 1
0→K
Repeat K=105
getKey→K
If K=92:Then
L(1)+1→L(1)
If L(1)=5:1→L(1)
Circle(–5,5,4,L(L(1)))
End
If K=93:Then
L(2)+1→L(2)
If L(2)=5:1→L(2)
Circle(5,5,4,L(L(2)))
End
If K=94:Then
L(3)+1→L(3)
If L(3)=5:1→L(3)
Circle(–5,–5,4,L(L(3)))
End
If K=82:Then
L(4)+1→L(4)
If L(4)=5:1→L(4)
Circle(5,–5,4,L(L(4)))
End
End
RecallGDB 0
AxesOn
Stop
Lbl 0
Circle(–5,5,4,12)
Circle(5,5,4,12)
Circle(–5,–5,4,12)
Circle(5,–5,4,12)
Goto 1




ARC84C:  Arc Length

Find the Arc Length of function Y1.  Once the arc length is calculated, the function is plotted in black and the arc length is plotted in red. 

Program:
FnOff :Func:FnOn 1
ClrDraw:Radian
Menu("USE Y?","YES",1,"NO",2)
Lbl 2
Input "Y, USE STRINGS:",Y
Lbl 1
GraphColor(1,BLACK)
Input "LOW:",A
Input "HIGH:",B
fnInt(√(1+nDeriv(Y,X,X)²),X,A,B)→L
Disp "ARC LENGTH=",L
Pause
For(K,A,B,ΔX)
Pt-On(K,Y(K),1,RED)
End
TextColor(BLUE)
Text(150,0,"ARC=")
Text(150,40,L)

Examples

Y1 = cos(X)*e^X from X = 1 to 2.   Arc Length = 4.7031139029…

Y1 = -2X^2 + 4X + 1 rom X = -2 to 2.   Arc Length = 20.7833…





AREABTWN:  Area Between Curves

This calculates the area between two curves, Y1 and Y2.  This program works best if you can set the graph screen to where the curves intersect at only two points.  The program first searches for two intersections, one from the left side of the graph screen (Xmin) and one from the right (Xmax).  After the area is calculated, both curves are graphed and the area between curves are shaded.  Function and Radian modes are used.

Program:
Func:Radian:FnOff :ClrDraw
FnOn 1:FnOn 2
Menu("USE Y/Y?","YES",1,"NO",2)
Lbl 2
Input "Y:",Y
Input "Y:",Y
Lbl 1
GraphColor(1,BLACK)
GraphColor(2,BLUE)
solve(Y-Y,X,Xmin)→A
solve(Y-Y,X,Xmax)→B
If A>B:Then
A→C:B→A:C→B:End
(A+B)/2→C
If A=B:Then
Disp "NO SOLUTION":Stop
End
If Y(C)≥Y(C):Then
fnInt(Y-Y,X,A,B)→I
Disp "AREA=",I
Disp "PRESS ENTER TO GRAPH"
Pause
Shade(Y,Y,A,B,1,1,GREEN)
Else
fnInt(Y-Y,X,A,B)→I
Disp "AREA=",I
Pause
Shade(Y,Y,A,B,1,1,GREEN)
End

Examples

The Standard Window is used.  Xmin = -10, Xmax = 10, Ymin = -10, Ymax = 10

Y1 = -2X^2 + 4X + 1, Y2 = X^2.   Area = 2.734721…

Y1 = 1.2X + .63, Y2 = -X^2 + 5X + 1.   Area = 10.58676675…


I plan to accomplish the same programs for the Casio Prizm soon.    Eddie

This blog is property of Edward Shore.  2015.

Saturday, July 12, 2014

Geometry: Brining Circles Together (Illustrations done with Desmos)

Before I get started with today's blog post, I want to share an awesome online mathematical application.  All illustrations on this blog entry were done with the Desmos free on-line graphing calculator.  You can graph functions, parametric equations, table plots, and polar equations – complete with shading.  Many users have fun using Demos to draw interesting and fun graphics.  There is no monetary cost to signing an account.  You can check out Desmos at www.desmos.com.  

The Desmos Screen







The Two Circles
Suppose we have two circles, both having a radius of 1 and are touching at the origin of the Cartesian plane. (The origin is point (0,0).)

An equation that describes the two circles are:
Red Circle (on the left):  y^2 + (x + 1)^2 = 1
Blue Circle (on the right):  y^2 + (x – 1)^2 = 1


The two circles:  each of them are touching at the origin.


Simply put, the area of the two circles is 2*π. 

Moving the Red Circle In

What happens to the total area when I move the red circle to the right?  A portion of the circles will overlap, as illustrated below:

Moving the red circle to the right - note the overlapping ellipse shaded in purple.
 
If we want the total area, we have to take the overlapping ellipse (now shaded in purple) in mind.    One approach to calculating the area of the shape would be:

A = area of the two circles – area of the overlapping ellipse

A = 2 * π  - E

Where E = area of the ellipse

This ensures that there is not a portion of the shape, particularly the purple overlap that otherwise would get counted twice.   Let the variable p represent the distance that the red circle moves.  

The equations become:

Red Circle (on the left):  y^2 + (x + 1 - p)^2 = 1

Blue Circle (on the right):  y^2 + (x – 1)^2 = 1

In general, the area of any ellipse is:  A = π*a*b, where a and b are the length of the semi-major and semi-minor axes.  

The horizontal length of the ellipse is p.  Hence the semi-horizontal (semi-major or semi-minor depending on p) axis of the overlapping ellipse is p/2.  

Finding the semi-vertical axis will require finding the points where the two circles intersect.  Interestingly, the circles intersect when x=p/2.  The center point of the ellipse is (p/2, 0)
Using the equation for the red circle:

y^2 + (x + 1 – p)^2  = 1
y^2 + (p/2 + 1 – p)^2 = 1
y^2 + (1 – p/2)^2 = 1
y^2 = 1 – (1 – p/2)^2
y = ±√(1 – (1 – p/2)^2)
y = ±√(1 – (1 – p + p^2/4))
y = ±√(-p^2/4 + p)

To verify that we get the same answer, let’s substitute x=p/2 for the blue circle:

y^2 + (x – 1)^2 = 1
y^2 + (p/2 – 1)^2 = 1
y^2 = 1 – (p/2 – 1)^2
y = ±√(1 – (p/2 – 1)^2)
y = ±√(1 – (p^4/2 – p + 1))
y = ±√(-p^2/4 + p)

Hence the points where the circles interest are (p/2, ±√(-p^2/4 + p)).  The semi-vertical axis has a length of √(-p^2/4 + p).  The area of the overlapping ellipse, E, is:

E = π*p/2*√(-p^2/4 + p)

Overall, the area of the shape is:

A = 2*π - π*p/2*√(-p^2/4 + p)


Example:  p = 1/2
A = 2*π - π*(1/2)/2*√(-(1/2)^2/4 + 1/2)
A = 2*π – π/4*√(-1/16 + 1/2)
A = 2*π  - π/4 * √7/4 ≈ 5.76370

Eddie


This blog is property of Edward Shore. 2014


Python – Earth’s Radius and Gravity in US Units

Python – Earth’s Radius and Gravity in US Units Introduction The following script, gravus2.py, estimates the Earth’s gravity i...