(21S) The Intersection Point of a Quadrilateral
|
08-13-2017, 04:13 PM
(This post was last modified: 08-13-2017 04:14 PM by Eddie W. Shore.)
Post: #1
|
|||
|
|||
(21S) The Intersection Point of a Quadrilateral
Original post: http://edspi31415.blogspot.com/2017/08/c...ction.html
This program calculates the coordinates of the center of quadrilateral. For the derivation, please see this link: http://edspi31415.blogspot.com/2017/08/g...nt-of.html Input: Program (the code and steps should be the same for the HP 20S): Code:
Variables – HP 21S: Code:
Example From top-left hand corner clockwise: (-1, 4), (4, 6), (5, -1), (0, 0) Results: X = 1.357142857 Y = 2.035714286 |
|||
02-27-2021, 05:28 PM
Post: #2
|
|||
|
|||
RE: (21S) The Intersection Point of a Quadrilateral
(08-13-2017 04:13 PM)Eddie W. Shore Wrote: This program calculates the coordinates of the center of quadrilateral. For the derivation, please see this link: http://edspi31415.blogspot.com/2017/08/g...nt-of.html Instead of solving for slope (which may be infinite), then solve for intersection P, we can use vectors. Let quadrilateral vertices be A,B,C,D, P = intersection of diagonals AC, BD P = A + k*(C-A) = B + k2*(D-B) // for some values of k, k2, both between 0 to 1 k*(C-A) + k2*(B-D) = B-A Let coordinates of A,B,C,D = (x1,y1), (x2,y2), (x3,y3), (x4,y4): k*(x3-x1) + k2*(x2-x4) = x2-x1 k*(y3-y1) + k2*(y2-y4) = y2-y1 Apply Cramers rules, solve for k: k = det([[x2-x1,x2-x4],[y2-y1,y2-y4]]) / det([[x3-x1,x2-x4],[y3-y1,y2-y4]]) Quote:From top-left hand corner clockwise: (-1, 4), (4, 6), (5, -1), (0, 0) With D = (x4, y4) = (0,0), k simplified greatly: k = det([[x1,y1], [x2,y2]]) / det([[x1-x3,y1-y3], [x2,y2]]) lua> x, y = {-1,4,5}, {4,6,-1} -- points A, B, C only lua> k = (x[1]*y[2]-y[1]*x[2]) / ((x[1]-x[3])*y[2] - (y[1]-y[3])*x[2]) lua> k 0.39285714285714285 lua> x[1]+k*(x[3]-x[1]), y[1]+k*(y[3]-y[1]) -- P = A + k*(C-A) 1.3571428571428572 2.0357142857142856 |
|||
03-02-2021, 03:27 PM
(This post was last modified: 03-02-2021 03:28 PM by Albert Chan.)
Post: #3
|
|||
|
|||
RE: (21S) The Intersection Point of a Quadrilateral
(02-27-2021 05:28 PM)Albert Chan Wrote: Let quadrilateral vertices be A,B,C,D, P = intersection of diagonals AC, BD Previous post had D = (0,0), to simplify calculations. If we instead let A = (0,0), it simplified more: k*C + k2*(B-D) = B Redo previous example, using complex numbers. lua> I = require'complex'.I lua> function det(z1,z2) return z1:real()*z2:imag() - z1:imag()*z2:real() end lua> B, C, D = -1+4*I, 4+6*I, 5-I -- assumed A = 0 lua> P = det(D,B) / det(C,B-D) * C -- det(B,B-D) = det(B,B) - det(B,D) = det(D,B) lua> P:real(), P:imag() 1.3571428571428572 2.0357142857142856 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)