demo/conicfit.test1.R

# The results should be the same on every system

GtoA(c(0,0,20,60,45))
#            A           B           C D E  F
# 0.0008910293 0.001986659 0.001886748 0 0 -1

AtoG(c(0.0551,-0.0908,0.1588,0.0489,-0.9669,0.1620))
#     2.7010
#     3.8166
#     6.5206
#     3.0323
#     0.3596

XY <- matrix(c(1,7,2,6,5,8,7,7,9,5,3,7,6,2,8,4),8,2,byrow=TRUE)
ParAini <- matrix(c(0.2500,0, 1.0000, 0, 0, -1.0000),ncol=1)
ParGini <- matrix(c(0,0,2,1,0),ncol=1)
LambdaIni=0.1
fit.conicLMA(XY,ParAini,LambdaIni)
# ParA =
#   0.05511764
#  -0.09080764
#   0.15881027
#   0.04892510
#  -0.96688118
#   0.16199516
# RSS = 1.373306
# iters = 19
# exitCode = 1

ParG <- matrix(c(0,0,2,1,0),ncol=1)
Residuals.ellipse(XY,ParG)
# RSS = 384.2782
# XYproj = 
# 0.3944672 0.9803565
# 0.8333160 0.9090633
# 1.4046612 0.7118509
# 1.7060134 0.5219000
# 1.8992524 0.3133848
# 1.0648226 0.8464858
# 1.9530846 0.2153257
# 1.9131915 0.2914182

Residuals.parabola(XY,ParG)
# RSS = 79.1011
# XYproj = 
# -0.9446164 7.339967
# -1.0877019 6.448033
# -0.5623941 9.244795
#  9.4160129 3.936344
#  9.6809916 4.146550
# -0.8758736 7.720868
#  6.2308252 1.639623
#  8.5522775 3.269133

Residuals.hyperbola(XY,ParG)
# RSS = 121.5344
# XYproj = 
# 4.026195 1.747158
# 4.309460 1.908628
# 7.326343 3.524035
# 8.481257 4.121035
# 9.248472 4.514815
# 5.413203 2.515093
# 5.655270 2.644905
# 8.051767 3.899710

ResidualsG(XY,ParG)

# RSS = 384.2782
# XYproj = 
# 0.3944672 0.9803565
# 0.8333160 0.9090633
# 1.4046612 0.7118509
# 1.7060134 0.5219000
# 1.8992524 0.3133848
# 1.0648226 0.8464858
# 1.9530846 0.2153257
# 1.9131915 0.2914182


ParG <- matrix(c(-0.6069,   -0.2967,    1.0653,    0.8921,    2.5118),ncol=1)
Residuals.ellipse(XY,ParG)
# RSS = 519.4693
# XYproj = 
# -0.52078906  0.628457218
# -0.32732457  0.564285163
# -0.11705355  0.449260953
# 0.08107554  0.283187917
# 0.26442742  0.039655137
# -0.25751192  0.531791919
# 0.33851755 -0.118432460
# 0.28515757  0.001469427

Residuals.parabola(XY,ParG)
# RSS = 32.95484
# XYproj = 
# 0.6058301 7.167270
# 0.3940013 6.660362
# 1.6857929 9.566469
# 9.0243338 4.402224
# 9.3000656 4.617941
# 0.9294287 7.914321
# 5.9214336 2.114360
# 8.1848658 3.756412

Residuals.hyperbola(XY,ParG)
# RSS = 199.976
# XYproj = 
# -2.300191 6.21576485
# -2.029225 5.06388857
# -2.311066 6.26151363
# 7.508594 0.19205606
# 9.337792 0.32625765
# -2.195592 5.77409053
# 6.148991 0.08848747
# 8.275714 0.24888170

ResidualsG(XY,ParG)
# RSS = 519.4693
# XYproj = 
# -0.52078906  0.628457218
# -0.32732457  0.564285163
# -0.11705355  0.449260953
# 0.08107554  0.283187917
# 0.26442742  0.039655137
# -0.25751192  0.531791919
# 0.33851755 -0.118432460
# 0.28515757  0.001469427


ParG <- matrix(c(1.9305,    3.8834,    2.7083,    5.0628,    1.9344),ncol=1)
Residuals.ellipse(XY,ParG)
# RSS = 11.23463
# XYproj = 
# 1.179379 6.492447
# 1.809734 6.690533
# 4.809109 6.914030
# 6.280755 6.250534
# 6.758217 5.081395
# 3.008524 6.932430
# 5.347346 2.768130
# 6.638370 4.479736

Residuals.parabola(XY,ParG)
# RSS = 73.415
# XYproj = 
# 2.014673 3.912605
# 2.371238 4.003746
# 3.924811 3.914716
# 5.186370 3.421094
# 6.960785 2.290922
# 2.963301 4.053047
# 6.453931 2.657018
# 6.819459 2.396130

Residuals.hyperbola(XY,ParG)
# RSS = 21.6496
# XYproj = 
# 1.202509 6.507749
# 1.662959 6.711452
# 4.514071 8.591344
# 5.142051 9.124465
# 8.935203 2.094484
# 2.791052 7.333120
# 5.998083 2.021532
# 8.004887 2.104206

ResidualsG(XY,ParG)
# RSS = 11.23463
# XYproj = 
# 1.179379 6.492447
# 1.809734 6.690533
# 4.809109 6.914030
# 6.280755 6.250534
# 6.758217 5.081395
# 3.008524 6.932430
# 5.347346 2.768130
# 6.638370 4.479736


fit.ellipseLMG(XY,ParGini,LambdaIni)
# ParG = 
# 2.6996048
# 3.8159535
# 6.5187313
# 3.0318866
# 0.3596244
# RSS = 1.373306
# iters = 15
# TF = FALSE


ParA <- matrix(c(0.250000000000000,0,1,0,0,-1),ncol=1)
XYproj=matrix(c(0.394467220216675,0.980356518335872,0.833315950425981,0.909063326557293,1.40466123643977,0.711850899213363,
1.70601340510202,0.521899957274429,1.89925244997324,0.313384799914835,1.06482258038841,0.846485805004280,1.95308457257492,
0.215325713960169,1.91319150256275,0.291418202297698),8,2,byrow=TRUE)
JmatrixLMA(XY,ParA,XYproj)
# Res = 
# 6.050023
# 5.222910
# 8.126720
# 8.366127
# 8.507936
# 6.450632
# 4.422961
# 7.127609
# J = 
# 0.07896262 0.1962432 0.48771689 0.2001754 0.4974893 0.5074575
# 0.37228918 0.4061298 0.44304649 0.4467563 0.4873659 0.5361188
# 1.24287117 0.6298593 0.31919861 0.8848192 0.4484066 0.6299164
# 2.15909047 0.6605043 0.20206006 1.2655765 0.3871624 0.7418327
# 3.17024292 0.5231037 0.08631435 1.6692056 0.2754261 0.8788751
# 0.63888956 0.5078883 0.40374825 0.5999963 0.4769699 0.5634706
# 3.57406160 0.3940369 0.04344219 1.8299574 0.2017511 0.9369576
# 3.26763984 0.4977284 0.07581422 1.7079523 0.2601561 0.8927242

A <- matrix(c(0,0,2,1,0),ncol=1)
XYproj=matrix(c(0.394467220216675,0.980356518335872,0.833315950425981,0.909063326557293,1.40466123643977,0.711850899213363,
1.70601340510202,0.521899957274429,1.89925244997324,0.313384799914835,1.06482258038841,0.846485805004280,1.95308457257492,
0.215325713960169,1.91319150256275,0.291418202297698),8,2,byrow=TRUE)
JmatrixLMG(XY,A,XYproj)
# Res = 
# 6.050023
# 5.222910
# 8.126720
# 8.366127
# 8.507936
# 6.450632
# 4.422961
# 7.127609
# J = 
# -0.1000877 -0.9949786 -0.01974066 -0.97543378 -0.2943648
# -0.2233782 -0.9747319 -0.09307230 -0.88609298 -0.6091947
# -0.4424096 -0.8968131 -0.31071779 -0.63839722 -0.9447890
# -0.6327882 -0.7743249 -0.53977262 -0.40412013 -0.9907565
# -0.8346028 -0.5508522 -0.79256073 -0.17262870 -0.7846555
# -0.2999981 -0.9539398 -0.15972239 -0.80749649 -0.7618325
# -0.9149787 -0.4035021 -0.89351540 -0.08688438 -0.5910553
# -0.8539762 -0.5203121 -0.81690996 -0.15162843 -0.7465926

A <- matrix(c(2.3565,4.9754,5.6771,2.3911,2.8565),ncol=1)
XYproj=matrix(c(1.0891,7.6824,2.3430,7.4515,4.4706,6.7556,6.2024,5.8267,7.6719,4.3308,3.0761,7.2561,5.9606,2.2544,7.8116,3.9557),8,2,byrow=TRUE)
JmatrixLMG(XY,A,XYproj)
# Res = 
# -0.6881922
# -1.4914762
# 1.3523297
# 1.4187314
# 1.4871712
# -0.2671674
# 0.2574329
# 0.1935382
# J = 
# -0.1294647 -0.9915840 -5.388770e-02 -0.9261150  1.60719450
# -0.2300217 -0.9731855 -6.619840e-03 -0.9907722  0.58269478
# -0.3915017 -0.9201774 -3.144056e-02 -0.9564592 -1.24839569
# -0.5621916 -0.8270070 -1.865556e-01 -0.7556544 -2.70199272
# -0.8929857 -0.4500849 -6.795243e-01 -0.2503009 -2.96800010
# -0.2847414 -0.9586044 -2.614241e-05 -0.9999495 -0.04040211
# -0.1528771  0.9882452 -3.159770e-01 -0.6049548  3.14575606
# -0.9734521 -0.2288907 -8.459661e-01 -0.1146510 -2.24125064

Try the conicfit package in your browser

Any scripts or data that you put into this service are public.

conicfit documentation built on May 2, 2019, 3:11 a.m.