Saturday, April 27, 2024

Casio fx-CG 50: Points on a Circle

 Casio fx-CG 50: Points on a Circle


Introduction and Derivation





Given the initial point on a circle (x, y). If the point travels on a circle a distance of arc length s, where is the new point on the circle? Assumption: The center of the circle lies on the point (0, 0).


In fact, we can have two points depending on the direction traveled: counter-clockwise or clockwise. The programs presented today will determine both points.


Points that lie on the circle have the same radius. Determine the required radius:

r = √(x^2 + y^2)


And since the circle is centered at (0, 0), we can determine the angle by:

θ = arctan(y/x) = arg(x + yi)


We will assume all angles are in radians.


The arc length can be used to determine the angle traveled. Let’s call this angle z:

s = r × z

z = s / r


The new points can be determined by:


x’ = r × cos(θ + z), y’ = r × sin(θ + z)


x’’ = r × cos(θ - z), y’’ = r × sin(θ - z)


Casio fx-CG 50 Basic: PTSONCIRC


Code:


ClrText

Blue “POINTS ON”

Blue “THE CIRCLE”

Blue “CENTER (0,0)”

Red “RADIANS”

Rad

“INITIAL X”? → X

“INITIAL Y”? → Y

“ARC LENGTH”? → S

Abs (X+Yi) → R

Arg (X+Yi) → θ

S ÷ R → Z

R × cos(θ + Z) → A

R × sin(θ + Z) → B

R × cos(θ - Z) → C

R × cos(θ - Z) → D

ClrText

Green Locate 1,3,”POINT 1”

Black Locate 1,4,A

Blue Locate 11,4,”,”

Black Locate 12,4,B

Green Locate 1,5,”POINT 2”

Black Locate 1,6,C

Blue Locate 11,6,”,”

Black Locate 12,6,D


For monochrome models, leave out the color commands (Blue, Red, Black, Green)


Casio fx-CG 50 Python: ptsoncirc.py


Code:


from math import *

print(“Points on\nthe circle.”)

print(“Center is at (0,0)”)

x=float(input(“initial x? “))

y=float(input(“initial y? “))

s=float(input(“arc length? “))

r=sqrt(x**2+y**2)

t=atan(x,y)

z=s/r

b,a=r*cos(t+z),r*sin(t+z)

d,c=r*cos(t-z),r*sin(t-z)

print(“Point 1”)

print(str(a),”,\n”,str(b))

print(“Point 2”)

print(str(c),”,\n”,str(d))


Examples


X: 5, Y: 6, S: 1.5

Point 1: (3.76280901, 6.84406811)

Point 2: (6.05333094, 4.93529983)


X: 4: Y: 5, S: 1

Point 1: (3.173620164, 5.561306956)

Point 2: (4.729016994, 4.316989492)



Python Pointers


Storing to Multiple Variables in One Line


We can store a value to multiple variables in one line. For example,


a = b = 7

Stores the value 7 to both the variables a and b.


We can store multiple values to multiple values to multiple variables in one line. For example:


a, b = 7, 8

Stores 8 to the variable b and 7 to the variable a. The expression works from the inside-out.


We could also have both uppercase and lowercase letters as different variables, such as A and a. I choose not to because I want to avoid confusion.



New Line Escape Character: \n


In a string, we can add \n (backslash, n) to create a new line.



Eddie


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