**HP Prime and Casio Prizm: Computation of “As-Built” Circular Alignments**

Special thanks
to Jason Foose for bringing the topic to my attention.

The program
ASBUILT determines radius and center point of an approximate circular
curve. The program uses the least
squares method using the following matrices:

A = [ [ 2*x1,
2*y1, -1] [ 2*x2, 2*y2, -1 ] [ 2*x3, 2*y3, - 1] [ 2*x4, 2*y4, -1 ] ]

X = [ [ x0 ] [
y0 ] [ f ] ]

L = [ [ x1^2 +
y1^2 ] [ x2^2 + y2^2 ] [ x3^2 + y3^2 ] [ x4^2 + y4^2 ] ]

The matrix X is
solved by: X = ( det(A) * A)¯¹ * det(A) * L

The input for
ASBUILT is a 4 x 2 matrix, consisting of each of the four points.

The example:

(x1, y1) =
(6975.82, 6947.93)

(x2, y2) =
(7577.11, 6572.6)

(x3, y3) =
(8084.03, 6071.29)

(x4, y4) =
(8431.38, 5542)

The input
matrix is:

[ [ 6975.82,
6947.93 ] [ 7577.11, 6572.6 ] [ 8084.03, 6071.29 ] [ 8431.38, 5542 ] ]

ASBUILT is an
approximation program.

**HP Prime Program: ASBUILT**

EXPORT ASBUILT(ma)

BEGIN

LOCAL ml,mx,n,r,l≔{};

// build L

FOR n FROM 1 TO 4 DO

l(n)≔ABS(ma(n))^2;

END;

ml≔list2mat(l,1);

// build A

ma≔2*ma;

ADDCOL(ma,[-1,-1,-1,-1],3);

// compute X

mx≔CAS.LSQ(ma,ml);

// compute radius

r≔√(mx(1,1)^2+mx(2,1)^2-mx(3,1));

// results

RETURN {mx,r};

END;

Example Output: { [ [x0][y0][f]], radius}

{ [ [
5587.37457087 ] [ 4053.99226137 ] [ 37351007.6568 ] ] , 3209.76637679 }

**Casio Prizm Program: ASBUILT**

“4 × 2 Mat [X,Y]”? →
Mat A

{4 , 1} → Dim Mat B

For 1 → N To 4

Mat A[N,1]² + Mat
A[N,2]² → Mat B[N,1]

Next

2 × Mat A → Mat A

Augment(Mat A,
[[-1][-1][-1][-1]]) → Mat A

(Trn Mat A × Mat A)¯¹
× Trn Mat A × Mat B → Mat C

√( Mat C[1,1]² + Mat
C[2,1]² - Mat C[3,1] ) → R

“RADIUS”

R ◢

Mat C

Example
Output:

[ [
5587.3745555 ] [ 4053.992245 ] [ 37351007.55 ] ]

Radius, R =
3209.766346

Source: Ghilani, Charles D. “Elementary
Surveying: An Introduction to Geomatics”
14

^{th}Edition. Pearson. 2014
This blog is
property of Edward Shore, 2016

Great work Eddie!I've always wondered about the 3rd term in the output matrix and what it actually is or does. In this case it equals 37351007.55 Any thoughts?

ReplyDelete