So my problem is this. I have a formula (see picture), according to which I'm supposed to calculate some coordinates, given in output field.
I made my formulas in php, but it returns the wrong results.
Formula :
$inpx =(string)3484481.0943; //input X
$inpy =(string)3144325.1033;//input Y
$inpz =(string)4305103.1740;//input Z
$dx=-2.0796; //delta X
$dy=-0.3484; //delta Y
$dz=1.7009; //delta Z
$rx=(string)(0.05465/3600)*(string)(M_PI/180);
$ry=(string)(-0.06718/3600)*(string)(M_PI/180);
$rz=(string)(0.06143/3600)*(string)(M_PI/180);
$k=(string)0.0181/(string)pow(10,6);
$n=1+$k;
$X84=$n*$inpx-$rz*$n*$inpy+$ry*$n*$inpz+$dx;
$Y84=$rz*$n*$inpx+$n*$inpy-$rx*$n*$inpz+$dy;
$Z84=-$ry*$n*$inpx+$rx*$n*$inpy+$n*$inpz+$dz;
$X84 = round($X84,4);
$Y84 = round($Y84,4);
$Z84 = round($Z84,4);
The results that I'm supposed to get
$X84 = 3484481.4163; $Y84 = 3144324.9149; $Z84 = 4305102.9848;
The results that I get
$X84 = 3484476.7392; $Y84 = 3144324.7089; $Z84 = 4305106.9208;
Would be appreciated if someone could find what I have wrong in my formula, because I have been messing with it for a few days now.
Updated:
After further consideration, I believe you have an error with the positive and negative sign on your inputed rv values.
$inpx =(float)3484481.0943; //input X
$inpy =(float)3144325.1033;//input Y
$inpz =(float)4305103.1740;//input Z
$dx=-2.0796; //delta X
$dy=-0.3484; //delta Y
$dz=1.7009; //delta Z
Before:
$rx=(float)(0.05465/3600)*(float)(M_PI/180);
$ry=(float)(-0.06718/3600)*(float)(M_PI/180);
$rz=(float)(0.06143/3600)*(float)(M_PI/180);
After and resulting in the correct results:
$rx=(float)(-0.05465/3600)*(float)(M_PI/180);
$ry=(float)(0.06718/3600)*(float)(M_PI/180);
$rz=(float)(-0.06143/3600)*(float)(M_PI/180);
Just by changing the positive and negative sign on all three rv values, I receive the expected results.
$k=(float)0.0181/(float)pow(10,6);
$n=1+$k;
For clarityI have also added some parentheses to the following function.
$X84=($inpx*$n)+(-$rz*$inpy*$n)+($ry*$inpz*$n)+$dx;
$Y84=($rz*$n*$inpx)+($n*$inpy)+(-$rx*$n*$inpz)+$dy;
$Z84=(-$ry*$n*$inpx)+($rx*$n*$inpy)+($n*$inpz)+$dz;
$X84 = round($X84,4);
$Y84 = round($Y84,4);
$Z84 = round($Z84,4);
print_r($X84); //3484481.4164
print_r($Y84); //3144324.9147
print_r($Z84); //4305102.9848
Hope this helps solving your problem!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With