Cartesian Coordinate transformation (3D and 2D)

The function performs both reverse and direct problem-solving based on dual quaternions between two Cartesian coordinate systems (3D and 2D)
105 Downloads
Updated 5 Apr 2024

View License

%
% DQA_3d_transformation (Asymmetric similarity) with dual quaternions
% using scaled quaternions
% reverse and direct problem
% Model: xyz2=(2*w_r'*s)+(w_r'*Q_r*xyz1)
% function performs both reverse and direct problem-solving based on dual quaternions between two 3D Cartesian coordinate system
% The function can also 2D transformation between given coordinate systems.
% INPUT:
% n :number of control points
% xyz1 = nx3 start system coordinate matrix ([x1 y1 z1])[in meter]
% xyz1 contain [ n control points xyz1]
% | x1 y1 z1 |
% xyz1=| x2 y2 z2 |
% | ........ |
% | xn yn zn |
% xyz2 = nx3 target system coordinate matrix ([x2 y2 z2])[in meter]
% xyz2 contain [ n control points xyz2 ]
% | X1 Y1 Z1 |
% xyz2=| X2 Y2 Z2 |
% | ........ |
% | Xn Yn Zn |
% if there are new point to be transformed (revers problem+direct problem)
% xyz1 = mx3 start system coordinate matrix
% the new points are added under the control points in the xyz1 matrix.
% m :number of total points (control points+new points to be transformed)
% | x1 y1 z1 |==>control points
% | x2 y2 z2 |==>control points
% | .............. |==>control points
% xyz1=| xn yn zn |==>control points
% | xn+1 yn+1 zn+1 |==>new points
% | .............. |==>new points
% | xm ym zm |==>new points
% (m-n)= new points to be transformed (if any) ]
% FOR 2D TRANSFORMATIONS
% All of Z1 and Z2 coordinates must be entered as zero.
% P = nx1 weighted of points
% m-n : number of new points to be transformed
% m must be greater than or equal n (m>=n)
% if m=n there is no new point to be transformed (revers problem)
% if m>n there is new point to be transformed (revers problem+direct problem)
% OUTPUT:
% q =[2 x 8] matrix dual quaternion elements [r0 r1 r2 r3 s0 s1 s2 s3] [unitless]
% first row contained scaled quaternions
% second row contained unit quaternions
% L = scale factor [unitless]
% T = translation vector (Tx,Ty,Tz)[in meter]
% angles = (e,p,w) rotation angles (x,y,z) [in radian]
% res = residual of coordinates [in meter]
% so = standard error of transformation [in meter]
% Cqq = covariance matrix of scaled quaternions
% (r0,r1,r2,r3,s0,s1,s2,s3)respectively
% Cpar = covariance matrix of transformation parameters
% (L,e,p,w,tx,ty,tz,0)respectively
%
% xyz_new=(m-n)x3 matrix is the coordinates of the new points calculated in the target system. (if m>n)
% xyz_new=[] (if m=n)
%==========================================================================
%==========================================================================
% SAMPLE INPUT DATA For 3D Transformations
% n=4 number of control point
% m=5 number of row of xyz1
% m-n=1 number of new point to be converted (if any)
% xyz1=[ 6432.5800 7254.1200 200.6000
% 6354.3700 5724.5800 174.5700
% 7221.4400 6355.0800 254.5800
% 6433.5800 7255.1200 201.6000
% 6533.5800 7055.1200 211.6000 ] this row belong to new points to be converted.
% xyz2=[ 4208.8321 2111.9343 4182.9434
% 2034.5929 2073.9091 4924.8221
% 3397.0341 1919.6811 5773.1190
% 4207.7300 2110.9400 4182.1100 ]
%
% P=[1 2 3 4] weight
%======================================
% SAMPLE INPUT DATA For 2D Transformations
% n=4 number of control point
% m=5 number of row of xyz1
% m-n=1 number of new point to be converted (if any)
% xyz1=[ 9043.7400 5208.7900 0
% 9218.4200 4833.4900 0
% 9000.0000 5000.0000 0
% 9220.0200 5166.9100 0
% 9242.7000 5039.3800 0
% 9106.1700 5050.7100 0] this row belong to new points to be % converted.
% xyz2= [ 4618.7200 4068.8300 0
% 5579.4100 1115.6000 0
% 4103.9800 2553.3800 0
% 5893.3800 3597.0300 0
% 5946.7000 2626.7000 0 ]
% P=[1 1 1 1] weight
% ======================================================
% Please refer to:
%
% Bektas, S.(2023) An expanded dual quaternion algorithm for 3D Helmert %transformation and determination of the VCV matrix of the transformation’s %parameters. Journal of Spatial Science, DOI: 10.1080/14498596.2023.2274997
% Bektas, S.(2017) Adjustment Calculus,Ondokuz Mayis University press,
% ISBN 975-7636-54-1 Samsun,Turkey
%
%====================================================================
% written by Sebahattin BEKTAS January 2023
% sbektas@omu.edu.tr

Cite As

Sebahattin Bektas (2024). Cartesian Coordinate transformation (3D and 2D) (https://www.mathworks.com/matlabcentral/fileexchange/90711-cartesian-coordinate-transformation-3d-and-2d), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.5

updated

1.1.4

updated

1.1.3

updated

1.1.2

The function has been extended to work in 3D and 2D

1.1.1

help menu updated

1.1.0

updated

1.0.9

expanded, added weights to data input, also added covariance matrix of transformation parameters

1.0.8

updated

1.0.7

update

1.0.6

update

1.0.5

update

1.0.4

update

1.0.3

update

1.0.2

update

1.0.1

update

1.0.0