Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 2.08 KB

README.md

File metadata and controls

28 lines (19 loc) · 2.08 KB

pt2d

Projective transformation matrix between two quadrangles on a 2D plane

A little aid to compute what's described in https://math.stackexchange.com/a/339033/412495

Matrix A (or B)

Matrix A or B.

The following is a Maxima symbolic definition of matrix A (the format is meaningful enough to be easily translatable to any other language format):

matrix(
	[(x_1*(x_2*(y_4-y_3)+x_3*(y_2-y_4)+x_4*(y_3-y_2)))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1)),	-(x_2*(x_1*(y_4-y_3)+x_3*(y_1-y_4)+x_4*(y_3-y_1)))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1)),	(x_3*(x_1*(y_4-y_2)+x_2*(y_1-y_4)+x_4*(y_2-y_1)))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1))],
	[(y_1*(x_2*(y_4-y_3)+x_3*(y_2-y_4)+x_4*(y_3-y_2)))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1)),	-(y_2*(x_1*(y_4-y_3)+x_3*(y_1-y_4)+x_4*(y_3-y_1)))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1)),	(y_3*(x_1*(y_4-y_2)+x_2*(y_1-y_4)+x_4*(y_2-y_1)))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1))],
	[(x_2*(y_4-y_3)+x_3*(y_2-y_4)+x_4*(y_3-y_2))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1)),	-(x_1*(y_4-y_3)+x_3*(y_1-y_4)+x_4*(y_3-y_1))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1)),	(x_1*(y_4-y_2)+x_2*(y_1-y_4)+x_4*(y_2-y_1))/(x_1*(y_3-y_2)+x_2*(y_1-y_3)+x_3*(y_2-y_1))]
)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