Skip to content

Commit

Permalink
Merge pull request dr-ni#2 from Geo-Linux-Calculations/master
Browse files Browse the repository at this point in the history
Strip code
  • Loading branch information
dr-ni authored Oct 27, 2020
2 parents f2202c3 + 614e397 commit 830fb9c
Show file tree
Hide file tree
Showing 7 changed files with 921 additions and 896 deletions.
24 changes: 14 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
CC=gcc
CFLAGS=-Wall -g
SRCS=src
PREFIX=/usr/local
BINS=bin
MANS=man/man1
DEST=/usr/local/bin/
MANDEST=/usr/share/man/man1
INSTALL=install
RM=rm -f

all: helmert3d helmparms3d

Expand All @@ -17,13 +19,15 @@ clean:
rm -f helmparms3d helmert3d

install:
cp helmparms3d $(DEST)
cp helmert3d $(DEST)
cp $(MANS)/helmparms3d.1 $(MANDEST)
cp $(MANS)/helmert3d.1 $(MANDEST)
$(INSTALL) -d $(PREFIX)/$(BINS)
$(INSTALL) -d $(PREFIX)/$(MANS)
$(INSTALL) -m 0755 helmparms3d $(PREFIX)/$(BINS)
$(INSTALL) -m 0755 helmert3d $(PREFIX)/$(BINS)
$(INSTALL) -m 0644 $(MANS)/helmparms3d.1 $(PREFIX)/$(MANS)
$(INSTALL) -m 0644 $(MANS)/helmert3d.1 $(PREFIX)/$(MANS)

uninstall:
rm -f $(DEST)/helmparms3d
rm -f $(DEST)/helmert3d
rm -f $(MANDEST)/helmparms3d.1
rm -f $(MANDEST)/helmert3d.1
$(RM) $(PREFIX)/$(BINS)/helmparms3d
$(RM) $(PREFIX)/$(BINS)/helmert3d
$(RM) $(PREFIX)/$(MANS)/helmparms3d.1
$(RM) $(PREFIX)/$(MANS)/helmert3d.1
4 changes: 2 additions & 2 deletions man/man1/helmert3d.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "helmert3d" 1 0.51 "26 Oct 2020" "User Manual"
.TH "helmert3d" 1 0.51 "27 Oct 2020" "User Manual"

.SH NAME
helmert3d
Expand All @@ -7,7 +7,7 @@ helmert3d
The 3D Helmert transformation.

.SH SYNOPSIS
helmert3d [xyz_filename] [helmert_param_filename]
helmert3d [xyz_filename] [helmert_param_filename] [xyz_output[=transformed.xyz]]

.SH FILES
.TP
Expand Down
2 changes: 1 addition & 1 deletion man/man1/helmparms3d.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "helmparms3d" 1 0.51 "26 Oct 2020" "User Manual"
.TH "helmparms3d" 1 0.51 "27 Oct 2020" "User Manual"

.SH NAME
helmparms3d
Expand Down
278 changes: 141 additions & 137 deletions src/helmert3d.c
Original file line number Diff line number Diff line change
@@ -1,137 +1,141 @@
/* Copyright (C) 2011 U. Niethammer, http://helmparms3d.sourceforge.net/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define VERS 0.51

int main(int argc, char* argv[]){
FILE *parmfile;
FILE *ifile;
FILE *ofile;
char ifilename[256];
char buf[256];
double tx=0.0;
double ty=0.0;
double tz=0.0;
double m=0.0;
double r11=0.0;
double r12=0.0;
double r13=0.0;
double r21=0.0;
double r22=0.0;
double r23=0.0;
double r31=0.0;
double r32=0.0;
double r33=0.0;
double x=0.0;
double y=0.0;
double z=0.0;
double xout=0.0;
double yout=0.0;
double zout=0.0;

printf("\n***********************************\n");
printf( "* 3D-Helmert Transformation v%1.2f *\n",VERS);
printf( "* 26.10.2020 *\n");
printf( "* (c) U. Niethammer *\n");
printf( "***********************************\n");
if(argc < 3){
printf("Syntax: %s [xyz_filename] [helmert_param_filename]\n\n",argv[0]);
printf("helmert parameter file format:\n");
printf(" r11 r12 r13\n r21 r22 r23\n r31 r32 r33\n tx ty tz\n m\n\n");
printf("xyz data file format:\n");
printf(" x[1] y[1] z[1]\n .. .. ..\n .. .. ..\n x[n] y[n] z[n]\n\n");
exit(1);
}
memset(ifilename,0,sizeof(ifilename));
strcpy(ifilename,argv[1]);
ifile = fopen( ifilename, "r");
if(ifile == NULL){
printf("Error opening %s\r\n",ifilename);
exit(-1);
}
memset(ifilename,0,sizeof(ifilename));
strcpy(ifilename,argv[2]);
parmfile = fopen( ifilename, "r");
if(parmfile == NULL){
printf("Error opening %s\r\n",ifilename);
exit(-1);
}
ofile = fopen( "transformed.xyz", "w");
if(ofile == NULL){
printf("Error writing %s\r\n","ixyz_helmert.xyz");
exit(-1);
}

printf("reading helmert parameters...\n");
if(fgets( buf, 128, parmfile)!=NULL){
sscanf( buf, "%lf %lf %lf", &r11, &r12, &r13);
}
else{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL){
sscanf( buf, "%lf %lf %lf", &r21, &r22, &r23);
}
else{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL){
sscanf( buf, "%lf %lf %lf", &r31, &r32, &r33);
}
else{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL){
sscanf( buf, "%lf %lf %lf", &tx, &ty, &tz);
}
else{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL){
sscanf( buf, "%lf", &m);
}
else{
printf("Error reading %s\n",ifilename);
}

//if(m>=0.0)m+=1.0;//ppm to real scaling factor
//if(m<0.0)m-=1.0; //ppm to real scaling factor
printf("%lf %lf %lf\n", r11 , r12 , r13);
printf("%lf %lf %lf\n", r21 , r22 , r23);
printf("%lf %lf %lf\n", r31 , r32 , r33);
printf("%lf %lf %lf\n", tx , ty , tz);
printf("%lf\n", m);

printf("...done\n");


printf("starting transformation...\n");
while(fgets( buf, 128, ifile)!=NULL){
sscanf( buf, "%lf %lf %lf", &x, &y, &z);
xout=tx+m*(x*r11+y*r12+z*r13);
yout=ty+m*(x*r21+y*r22+z*r23);
zout=tz+m*(x*r31+y*r32+z*r33);
fprintf(ofile,"%lf %lf %lf\n", xout , yout , zout);
}
printf("...done\nResults written to transformed.xyz\n");
return(0);
}


/* Copyright (C) 2011 U. Niethammer, http://helmparms3d.sourceforge.net/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define VERS 0.51

int main(int argc, char* argv[])
{
FILE *parmfile;
FILE *ifile;
FILE *ofile;
char *ifilename = "";
char *pfilename = "";
char *ofilename = "transformed.xyz";
char buf[256];
double tx=0.0, ty=0.0, tz=0.0;
double m=0.0;
double r11=0.0, r12=0.0, r13=0.0;
double r21=0.0, r22=0.0, r23=0.0;
double r31=0.0, r32=0.0, r33=0.0;
double x=0.0, y=0.0, z=0.0;
double xout=0.0, yout=0.0, zout=0.0;

printf("\n***********************************\n");
printf( "* 3D-Helmert Transformation v%1.2f *\n",VERS);
printf( "* 26.10.2020 *\n");
printf( "* (c) U. Niethammer *\n");
printf( "***********************************\n");
if(argc < 3)
{
printf("Syntax: %s [xyz_filename] [helmert_param_filename] [xyz_output[=transformed.xyz]]\n\n",argv[0]);
printf("helmert parameter file format:\n");
printf(" r11 r12 r13\n r21 r22 r23\n r31 r32 r33\n tx ty tz\n m\n\n");
printf("xyz data file format:\n");
printf(" x[1] y[1] z[1]\n .. .. ..\n .. .. ..\n x[n] y[n] z[n]\n\n");
exit(1);
}
ifilename = argv[1];
ifile = fopen( ifilename, "r");
if(ifile == NULL)
{
printf("Error opening %s\r\n",ifilename);
exit(-1);
}
pfilename = argv[2];
parmfile = fopen( pfilename, "r");
if(parmfile == NULL)
{
printf("Error opening %s\r\n",ifilename);
exit(-1);
}
if(argc > 3)
{
ofilename = argv[3];
}
ofile = fopen( ofilename, "w");
if(ofile == NULL)
{
printf("Error writing %s\r\n","ixyz_helmert.xyz");
exit(-1);
}

printf("reading helmert parameters...\n");
if(fgets( buf, 128, parmfile)!=NULL)
{
sscanf( buf, "%lf %lf %lf", &r11, &r12, &r13);
}
else
{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL)
{
sscanf( buf, "%lf %lf %lf", &r21, &r22, &r23);
}
else
{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL)
{
sscanf( buf, "%lf %lf %lf", &r31, &r32, &r33);
}
else
{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL)
{
sscanf( buf, "%lf %lf %lf", &tx, &ty, &tz);
}
else
{
printf("Error reading %s\n",ifilename);
}
if(fgets( buf, 128, parmfile)!=NULL)
{
sscanf( buf, "%lf", &m);
}
else
{
printf("Error reading %s\n",ifilename);
}

printf("%lf %lf %lf\n", r11 , r12 , r13);
printf("%lf %lf %lf\n", r21 , r22 , r23);
printf("%lf %lf %lf\n", r31 , r32 , r33);
printf("%lf %lf %lf\n", tx , ty , tz);
printf("%lf\n", m);

printf("...done\n");

printf("starting transformation...\n");
while(fgets( buf, 128, ifile)!=NULL)
{
sscanf( buf, "%lf %lf %lf", &x, &y, &z);
xout=tx+m*(x*r11+y*r12+z*r13);
yout=ty+m*(x*r21+y*r22+z*r23);
zout=tz+m*(x*r31+y*r32+z*r33);
fprintf(ofile,"%lf %lf %lf\n", xout , yout , zout);
}
printf("...done\nResults written to %s\n", ofilename);
return(0);
}
Loading

0 comments on commit 830fb9c

Please sign in to comment.