Showing posts with label radius. Show all posts
Showing posts with label radius. Show all posts

Monday, January 5, 2026

Casio fx-CG 100 Python: Clothoid Curve Analysis

Casio fx-CG 100 Python: Clothoid Curve Analysis



Introduction



The clothoid is a mathematical curve where its curvature is in proportion to the distance traveled from the origin. This property allows the curve to serve many applications including connecting railways, designing roller coasters, and traffic distribution.







Let:

L: arc length of the curve traveled

R: radius from the center of the clothoid to the point on the curve

(x, y): point on the clothoid curve with curve length L and radius R

A: parameter, where A = √(R * L)

Θ: angle between the radius and line of the center point and a point on the x-axis, where Θ = L^2 ÷ (2 * A^2)



The point on the curve is determined by a variation of the Fresnel Integrals:

x = A * √2 * ∫( cos(u^2) du, u = 0 to u = t)

y = A * √2 * ∫( sin(u^2) du, u = 0 to u = t)



The Python program uses infinite series to calculate the point (x, y).



The Clothoid curve is also known as the Cornu spiral or the Euler spiral.


Casio fx-CG 100 Program: clothoid.py


# Clothoid Curve Analysis

# template of infinite series

# Eddie W. Shore, 11/23/2025


from math import *


# factorial function

def fact(n):

  f=1

  if n<=1:

    return 1

  else:

    for i in range(2,n+1):

      f*=i

    return f


# main program

print("Clothiod Analysis\nCornu Spiral")

r=eval(input("radius: "))

l=eval(input("arc length: "))

a=sqrt(r*l)

t=l**2/(2*a**2)


# c: cosine, s=sine

c=0

s=0

# set term artificially high

w=100

# set counter at beginning

n=0

# series loop

while abs(w)>=1e-20:

  cc=(-1)**n*t**(4*n+1)/(fact(2*n)*(4*n+1))

  ss=(-1)**n*t**(4*n+3)/(fact(2*n+1)*(4*n+3))

  w=max(cc,ss)

  c+=cc

  s+=ss

  n+=1

# answer

x=a*sqrt(2)*c

y=a*sqrt(2)*s

print("constant: {0:.12f}".format(a))

print("angle: {0:.12f}".format(t))

print("x: {0:.12f}".format(x))

print("y: {0:.12f}".format(y))


Example


Input:

Radius: r = 1.75

Arc Length: l = 4.00


Results:

constant (a): 2.645751311065

angle (degrees): 1.142857142857°

x: 3.602081584381

y: 1.646831998544



Sources


Autodesk, Inc. “About Spiral Definitions” Autodesk Civil 3D Help. https://help.autodesk.com/view/CIV3D/2025/ENU/?guid=GUID-DD7C0EA1-8465-45BA-9A39-FC05106FD822. 2025. Retrieved November 19, 2025.


Constantin. “The Clothoid” A railway track blog. https://railwaytrackblog.com/2016/07/03/the-clothoid/comment-page-1/ March 7, 2016. Retrieved November 19, 2025.


Gombáu, Alberto. “The clothoid: geometry that unites mathematics, engineer and design”. https://medium.com/@gombau/the-clothoid-geometry-that-unites-mathematics-engineering-and-design-6323de37e979. April 11, 2025. Retrieved November 19, 2025.



Eddie


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

Circular Sector: Finding the Radius and Angle

 Circular Sector: Finding the Radius and Angle





Here is the problem:


We are given the area of the circular segment, A, and the arc length of the segment, s. What is the radius, r, and the angle, θ?


The arc length is calculated as: s = θ * r


The area is calculated as: A = ½ * θ * r^2


We have the system of equations:


A = ½ * θ * r^2

s = θ * r


Divide A by s:


A / s= (½ * θ * r^2) / (θ * r)

A / s = r / 2

2 * A / s = r


Then

s = r * θ

θ = s / r = s^2 / (2 * A)


In summary:

r = 2 * A / s

θ = s / r = s^2 / (2 * A)


Note that the angle is in radians.

Example


Example 1:

s = 4, A = 30


r = (2 * 30) / 4 = 15

θ = 4 / 15 ≈ 0.266666667


Example 2:

s = 10.5, A = 31.8


r = (2 * 30) / 4 = 212/35 ≈ 6.057142857

θ = 10.5 / (212/35) = 735/424 ≈ 1.733490566


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.

Sunday, April 28, 2024

TI 30Xa Algorithms: Fundamental Horizontal Circle Calculations

 TI 30Xa Algorithms: Fundamental Horizontal Circle Calculations



Introduction and Formulas





Given the following:


r = radius of the curve

Δ = central angle, or the angular sweep of the curve. The angle is usually given in whole degrees or in surveying, degrees-minutes-seconds.


We can calculate the following:


The length of the tangent line to the central meeting point:

t = r × tan( Δ / 2 )


The linear distance from where the curve begins to the point the curve ends, known as the chord distance:

c = 2 × r × sin( Δ / 2 )


The distance of the curve from the end points, known as the arc length:

s = (Δ° / 180°) × π × r


Note the formula for arc length assumes that the angle is in degrees. If the angle is in radians, the formula for arc length reduces to s = Δ rad × r.



Procedure


The procedure is made for the TI-30Xa, where we can take advantage of the three memory registers it has. You can use another calculator, except most basic scientific calculators only have one memory register; you will just have type in one of the extra variables.


1. Check the angle mode. We should be in degrees mode, which is indicated by the DEG indicator. If not, press the [ DRG ] key until degrees mode is selected.


2. Enter the central degree (Δ).


If the degree is in whole degrees, just enter the angle and store into memory register 1. ( [ STO ] [ 1 ] ).


If the degree is in degrees-minutes-seconds format (known as DMS or sometimes as HMS), enter the angle in DD.MMSSS format. Then press [ 2nd ] [ + ] {DMS>DD} to convert the angle into whole degrees. Then store the result into memory register 1.


3. Enter the radius length and store in memory register 2. ( [ STO ] [ 2 ] ).


Memory registers:

M1 = Δ; M2 = r


4. Calculate the tangent length, t:


[ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ TAN ] [ × ] [ RCL ] 2 [ = ]


5. Calculate the chord distance, c:


2 [ × ] [ RCL ] 2 [ × ] [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ SIN ] [ = ]


6. Calculate the arc length, s:


[ RCL ] 1 [ × ] [ π ] [ × ] [ RCL ] 2 [ ÷ ] 180 [ = ]


Examples


Let’s assume for the following examples Degrees mode is set (DEG).


Example 1:

r = 150 ft (it can be any length unit as long as you keep it consistent)

Δ = 60° (whole degrees)


60 [ STO ] 1

150 [ STO ] 2


t: [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ TAN ] [ × ] [ RCL ] 2 [ = ]

t = 86.60254038 ft


c: 2 [ × ] [ RCL ] 2 [ × ] [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ SIN ] [ = ]

c = 150 ft

(In this case, the chord length is the same as the radius. Why? There is a geometric reason.)


s: [ RCL ] 1 [ × ] [ π ] [ × ] [ RCL ] 2 [ ÷ ] 180 [ = ]

s = 157.0796327 ft



Example 2:

r = 324 ft

Δ = 92°22’18” (92 degrees, 22 minutes, 18 seconds)


92.2218 [ 2nd ] [ + ] {DMS>DD} [ STO ] 1

324 [ STO ] 2


t: [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ TAN ] [ × ] [ RCL ] 2 [ = ]

t = 337.6968953 ft


c: 2 [ × ] [ RCL ] 2 [ × ] [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ SIN ] [ = ]

c = 467.5897175 ft


s: [ RCL ] 1 [ × ] [ π ] [ × ] [ RCL ] 2 [ ÷ ] 180 [ = ]

s = 522.3494689 ft



Source

Hewlett-Packard Company. HP-46 sample applications. Loveland, CO. February 1,1975. Part No. 00046-90018. pg. 104-105



Happy Birthday, Smokey!


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.

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.


Saturday, April 20, 2024

Sharp EL-9300 Programs

Sharp EL-9300 Programs


Today’s blog entry takes us to the 1992 Sharp’s EL-9300 graphing calculator. On January 10, 2022, I gave a review of this calculator:

https://edspi31415.blogspot.com/2022/01/retro-review-sharp-el-9300c.html



The programs should also work on the EL-9200. Spaces are added for readability.



Sharp EL-9300 Program: polygon2


The program polygon2 calculates four properties of regular polygons:

* The internal angle of the polygon

* The length of the polygon’s apothem

* The length of the polygon’s radius

* The area of the polygon


A regular polygon is a polygon whose sides all have equal length and all the internal angles are equal.


REAL Mode

Print “Set Degrees 1st”

Wait 1

Print “number of sides”

Input n

Print “side length”

Input x

angle = (n – 2) / n * 180

apothem = x / 2 * tan (angle / 2)

radius = x / (2 * cos (angle / 2) )

area = n * x * apothem / 2

ClrT

Print angle

Print apothem

Print radius

Print area



Note that the calculator must be set in Degrees mode prior to running this program. To set the degrees mode, press [ SET UP ], [ B ], [ 1 ]. Note that this won’t set the angle mode indicator in the program as the angle mode change takes place outside of the program script.


Examples


Inputs: n = 6, x = 8

Outputs:

angle = 120 (internal angle)

apothem = 6.92820323

radius = 8

area = 166.2768775



Inputs: n = 12, x = 1.5

Outputs:

area = 150

apothem = 2.799038106

radius = 2.897777479

area = 25.19134295



Sharp EL-9300 Program: agm


The program agm calculates the arithmetic-geometric mean between two numbers x and y.


(x + y) / 2

√(x * y)


The program also asks for the tolerance. If the tolerance is small, it means we are asking for better accuracy at the expense of additional calculations.


REAL Mode

ClrT

Print “arithmetic/”

Print “geometric mean”

Input x

Input y

Print “tol (10^-nn)”

Input tol

Label loop

a = (x + y) / 2

g = √(x * y)

x = a

y = g

If abs(a – g) >= tol Goto loop

ClrT

Print “results”

Print a

Print g

End


Examples


Inputs: x = 15, y = 70, tol = 10^-6

Outputs:

a = 37.28076573

g = 37.28076573


Inputs: x = 1649, y = 1248, tol = 1E-7

Outputs:

a = 1441.519759

g = 1441.519759


The EL-9300 is pretty quick.



Sharp EL-9300: quadratic


The program quadratic solves the quadratic equation:


a * x^2 + b * x + c = 0


where a, b, and c can be real or complex numbers.


COMPLEX Mode

ClrT

Print “ax^2+bx+c=0”

Print “complex numbers”

Input a

Input b

Input c

x = (-b + √(b^2 – 4 * a * c)) / (2 * a)

z = x - √(b^2 – 4 * a * c) / a

ClrT

Print “solutions=”

Print x

Print z

End


Examples


Inputs:

a = 4 + 3i, b = 2 – 5i, c = 3i

Solutions:

x = 0.346818295 – 0.288439118i

z = -0.066818295 + 1.328439118i


Inputs:

a = 2, b = -6i, c = -4 + 8i

Solutions:

x = 1.370730624 + 0.040924113i

z = -1.370730624 + 2.959075887i



Sharp EL-9300 Program: twobytwo


The program twobytwo solves the simultaneous set of equations:


a * x + b * y = e

c * x + d * y = f


where a, b, c, d, e, and f can be complex numbers.


COMPLEX Mode

Print “2x2 system”

Print “complex numbers”

Print “A=((a,b)(c,d))”

Input a

Input b

Input c

Input d

Print “B=((e)(f))”

Input e

Input f

g = a * d – b * c

h = e * d – f * b

i = a * f – c * e

x = h / g

y = i / g

ClrT

Print “solutions=”

Print x

Print y

End



Examples


Input:

a = 3 + 2i, b = -i

c = 3 – 2i, d = 1 – i

e = 0, f = 5i

Outputs:

x = -0.660377358 + 0.188679245i

y = -0.754716981 + 2.358490566i


Input:

a = 3, b = -6

c = 3i, d = 6i

e = 1, f = -i

Outputs:

x = 0

y = -0.166666667




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.


Saturday, April 6, 2024

Radius and Apothem of Regular Polygons

Radius and Apothem of Regular Polygons


On this blog, let’s calculate the lengths of a regular polygon’s radius, apothem, and area knowing only the side length and internal angle.



A regular polygon is a polygon in which every side has an equal length, and every internal angle is equal.


Let x be the length of one side of the regular polygon, and θ be the internal angle of the polygon where:


θ = (n – 2) / n × 180°




The radius (r) of the regular polygon is a line segment from a vertex to the center of the polygon. The radius bisects the vertex, therefore cutting the internal angle in half.

The apothem (a) is a line segment from the center of the polygon to the center of the polygon’s line segment. If we extend the apothem beyond the border, the apothem splits the length of the side segment in half.

Zooming in, a right triangle is formed between the radius, apothem, and half of the polygon line segment.


By trigonometry:


tan (θ / 2) = a / (x / 2)

a = (x / 2) × tan (θ / 2)


and


cos (θ / 2) = (x / 2) ÷ r

r = x / (2 × cos (θ / 2))


Knowing the apothem, the area of the regular polygon is:


area = perimeter × a / 2


where the perimeter = n × x


Then:


area = (n × x) × a / 2

= 1 / 2 × n × x × a

= 1 / 2 × n × x × (x / 2 × tan(θ / 2))

= 1 / 4 × n × x^2 × tan(θ / 2)



Another Formula for an Area’s Regular Polygons


The area of a regular polygon is often stated as:


area = 1 / 4 × n × x^2 / (tan (180° / n)) = 1 / 4 × n × x^2 × cot (180° / n))


We can show that the two formulas for area are equivalent:


Note that:

θ = (n – 2) / n × 180°

θ = 180° - 360° / n

Divide both sides by 2:

θ / 2 = 90° - 180° / n

180° / n = 90° - θ / 2 [ I ]




Observe that the trigonometric identity, for any angle α:

tan(90° - α) = 1 / tan(α) = cot(α)

and

cot(90° - α) = 1 / cot(α) = tan(α) [ II ]


Then:

area = 1 / 4 × n × x^2 × tan(θ / 2)

= 1 / 4 × n × x^2 × cot(90° - θ / 2) [ II ]

= 1 / 4 × n × x^2 × cot(180° / n) [ I ]

= 1 / 4 × n × x^2 / tan(180° / n) [ I ]


In Summary:

Internal Angle: θ = (n – 2) / 2 × 180°

Apothem: a = (x / 2) × tan (θ / 2)

Radius: r = x / (2 × cos (θ / 2))

Area = 1 / 4 × n × x^2 × tan(θ / 2) = 1 / 4 × n × x^2 / tan(180° / n)

(Note: 180° = π radians)



Table of Apothem and Radius, with side length of 1


n

θ (in degrees)

θ / 2 (in degrees)

a (to 5 decimal places)

r (to 5 decimal places)

3

60

30

0.28868

0.57735

4

90

45

0.5

0.70711

6

120

60

0.86603

1

8

135

67.5

1.20711

1.30656

12

150

75

1.86603

1.93185


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.

Numworks (Python): Parallelograms Described by Vectors

Numworks (Python): Parallelograms Described by Vectors Introduction The script drawpgram.py draws a parallelogram constructed by ...