c# - Matrix / coordinate transformation order -



c# - Matrix / coordinate transformation order -

i have 2 array of points:

point [] original; , point [] transformed;

these transformed array re-create of original transformations applied. example:

matrix.rotate(5f); matrix.scale(.8f, 1.1f); matrix.translate(30f, 18f); matrix.transformpoints(transformed); the original points are known. the transformation values are known. the order in transformations applied not known.

how can calculate / infer order of transformations?

edit

there 1 round of transformation. a round contain @ 3 transformations below. the transformations applied combination on rotate, scale , translate.

to give real-world context, consider having image known points of interest. print image, scan , seek read again. image contains orientation markers allow me calculate transformations applied during scanning process.

now, brute forcefulness approach be:

read scanned image. calculate rotation on scanned image. apply rotation on scanned image. calculate scale on rotated image. apply scale on rotated image. calculate translation on scaled image. apply translation on scaled image.

you can read points of involvement processed image using original points if there no transformation. of course of study method expensive. 500mb image need have @ to the lowest degree 2 copies in memory @ time , have transformed using graphics object.

the premise of question read image once, calculate transformations , apply them coordinates rather image itself. utilize transformed coordinates read points of interest. problem of 'order of transformations' comes in. helpful answers below , hope clears context.

for number of transformations looking @ brute forcefulness easiest approach rather trying mathematical analyses on things (i'm not 100% sure if that's possible hard).

for 3 different transforms (a,b,c) have 6 different ways can apply them. are:

abc acb bac bca cab cba

so each of apply them in order input , check whether final product matches output.

if don't have 1 of specific transforms left 2 options of order. may best dealt using above 6 options , applying identity matrix (or no-op) missing transform is. of course of study need checks prevent duplicating same transform order.

for optimal performance don't need check points in array - if first point doesn't match no need check more. of course of study want check of points in array match ensure not chance first point transformed works. can check trivial transformations (such scale factor of 1) , treat them not existing because appear @ position @ might assume @ origin (or end or middle - personal preference).

lastly there still possibility of ambiguity. not , little set of input points becomes unlikely. point need aware of though. see below give-and-take on special case ambiguity becomes lot more likely.

i hope plenty going in right direction. can't write total code because have no thought how transformation info stored , on.

after brief give-and-take whether translation commutative or not (eg doing b same doing b a) believe not. in special case scaling of x , y equal scaling , rotation commutative syntax used here suggests scaling has 2 factors presume x , y scale factors. means scaling , rotation not commutative in case. translations never commutative (imagine trivial case translation move point origin , can see matters).

nocturn's point (in comments) on commutativity apply though if scale same on x , y axes. means if have such scale , next rotation 2 possible transformation orders valid. there no way distinguish between two.

c# matrix order coordinates transformation

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -