Skip to content

Commit

Permalink
1.0.1: Added helmdiff3d
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Feb 11, 2021
1 parent 40231a4 commit 4a16f2e
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 12 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BINS=bin
EXAMPS=examples
MANS=man/man1

all: helmert3d helmparms3d
all: helmert3d helmparms3d helmdiff3d

libsvdm.a: $(SRCS)/svdm.c
$(CC) $(CFLAGS) -c -o $(SRCS)/svdm.o $^
Expand All @@ -24,32 +24,41 @@ helmert3d: $(SRCS)/helmert3d.c
helmparms3d: $(SRCS)/helmparms3d.c libsvdm.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

helmdiff3d: $(SRCS)/helmdiff3d.c
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

pdfman: # not working for win
groff -m man -T ps $(MANS)/helmert3d.1 > man_helmert3d.ps
ps2pdf man_helmert3d.ps man_helmert3d.pdf
groff -m man -T ps $(MANS)/helmparms3d.1 > man_helmparms3d.ps
ps2pdf man_helmparms3d.ps man_helmparms3d.pdf
groff -m man -T ps $(MANS)/helmdiff3d.1 > man_helmdiff3d.ps
ps2pdf man_helmdiff3d.ps man_helmdiff3d.pdf
$(RM) *.ps

clean: # not working for win
$(RM) helmparms3d helmert3d libsvdm.a $(SRCS)/svdm.o *.pdf
$(RM) helmparms3d helmert3d helmdiff3d libsvdm.a $(SRCS)/svdm.o *.pdf

install:
$(INSTALL) -d $(PREFIX)/$(BINS)
$(INSTALL) -d $(PREFIX)/$(MANS)
$(INSTALL) -d $(DOCS)/$(EXAMPS)
$(INSTALL) -m 0755 helmparms3d $(PREFIX)/$(BINS)
$(INSTALL) -m 0755 helmert3d $(PREFIX)/$(BINS)
$(INSTALL) -m 0755 helmdiff3d $(PREFIX)/$(BINS)
$(INSTALL) -m 0644 README.md $(DOCS)
$(INSTALL) -m 0644 LICENSE $(DOCS)
$(INSTALL) -m 0644 $(EXAMPS)/testpoints_src.txt $(DOCS)/$(EXAMPS)
$(INSTALL) -m 0644 $(EXAMPS)/testpoints_dest.txt $(DOCS)/$(EXAMPS)
$(INSTALL) -m 0644 $(MANS)/helmparms3d.1 $(PREFIX)/$(MANS)
$(INSTALL) -m 0644 $(MANS)/helmert3d.1 $(PREFIX)/$(MANS)
$(INSTALL) -m 0644 $(MANS)/helmdiff3d.1 $(PREFIX)/$(MANS)

uninstall:
$(RM) $(PREFIX)/$(BINS)/helmparms3d
$(RM) $(PREFIX)/$(BINS)/helmert3d
$(RM) $(PREFIX)/$(BINS)/helmdiff3d
$(RMD) $(DOCS)
$(RM) $(PREFIX)/$(MANS)/helmparms3d.1
$(RM) $(PREFIX)/$(MANS)/helmert3d.1
$(RM) $(PREFIX)/$(MANS)/helmdiff3d.1
53 changes: 53 additions & 0 deletions man/man1/helmdiff3d.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.TH "helmdiff3d" 1 1.0.1 "11 Feb 2021" "User Manual"

.SH NAME
helmdiff3d

.SH DESCRIPTION
Diff 3D Helmert transformation Tool

.SH SYNOPSIS
helmdiff3d [xyz_src_infilename] [xyz_dest_infilename] [xyz_diff_outfilename]

.SH FILES
.TP
xyz data file format:

x[1] y[1] z[1]
.. .. ..
.. .. ..
x[n] y[n] z[n]

.SH EXAMPLE
export EXAMP=/usr/share/doc/helmert3d/examples/

helmparms3d $EXAMP/testpoints_src.txt $EXAMP/testpoints_dest.txt testparms.txt
helmert3d $EXAMP/testpoints_src.txt testparms.txt destpoints.txt
helmdiff3d $EXAMP/testpoints_dest.txt destpoints.txt diffpoints.txt

.SH COPYRIGHT
helmert3d:

Copyright (c) 2020 U. Niethammer

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.

.SH SEE ALSO
helmparms3d(1),
helmert3d(1)

.SH CONTACT
Website: https://github.com/dr-ni/helmert3d

132 changes: 132 additions & 0 deletions src/helmdiff3d.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* 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 "helmert3d.h"

static size_t get_m_size(char *filename)
{
FILE *ptsfile;
char buf[256];
size_t linecount=0;

memset(buf, 0, sizeof(buf));
ptsfile = fopen( filename, "r");
if(ptsfile == NULL)
{
fprintf(stderr,"Error opening %s\r\n",filename);
exit(EXIT_FAILURE);
}
// Count points
while(fgets( buf, 128, ptsfile)!=NULL)
{
if( strcmp(buf,"\n") != 0 && strcmp(buf,"\r\n") != 0 && strcmp(buf,"\0") != 0)
{
linecount++;
}
else
{
fprintf(stderr,"Error, %s: wrong data format\n",filename);
exit(EXIT_FAILURE);
}
}
(void)fclose(ptsfile);
return(linecount);
}

int main(int argc, char* argv[])
{
FILE *ifile;
FILE *cfile;
FILE *ofile;
char *ifilename = "";
char *cfilename = "";
char *ofilename = "diff.xyz";
char ibuf[256], cbuf[256];
double xs=0.0, ys=0.0, zs=0.0;
double xc=0.0, yc=0.0, zc=0.0;
double xout=0.0, yout=0.0, zout=0.0;
size_t l=0;
int stat=0;

fprintf(stdout,"\n*******************************\n");
fprintf(stdout, "* helmdiff3d v%s *\n",VERS);
fprintf(stdout, "* (c) U. Niethammer 2020 *\n");
fprintf(stdout, "*******************************\n");

if(argc < 3)
{
fprintf(stdout,"\nSyntax: %s [xyz_src_infilename] [xyz_dest_infilename] [xyz_diff_outfilename]\n\n",argv[0]);
fprintf(stdout,"xyz data file format:\n");
fprintf(stdout," x[1] y[1] z[1]\n .. .. ..\n .. .. ..\n x[n] y[n] z[n]\n\n");
exit(EXIT_FAILURE);
}
fprintf(stdout,"Reading points...\n");
ifilename = argv[1];
l = get_m_size(ifilename);
fprintf(stdout,"Found %lu points\n",(unsigned long)l);
ifile = fopen( ifilename, "r");
if(ifile == NULL)
{
fprintf(stderr,"Error opening %s\n",ifilename);
exit(EXIT_FAILURE);
}
cfilename = argv[2];
l = get_m_size(cfilename);
fprintf(stdout,"Found %lu points\n",(unsigned long)l);
cfile = fopen( cfilename, "r");
if(cfile == NULL)
{
fprintf(stderr,"Error opening %s\n",cfilename);
exit(EXIT_FAILURE);
}
if(argc > 3)
{
ofilename = argv[3];
}
ofile = fopen( ofilename, "w");
if(ofile == NULL)
{
fprintf(stderr,"Error writing %s\n",ofilename);
exit(EXIT_FAILURE);
}

fprintf(stdout,"Starting diff...\n");
while(fgets( ibuf, 128, ifile)!=NULL && fgets( cbuf, 128, cfile)!=NULL)
{
stat=sscanf( ibuf, "%lf %lf %lf", &xs, &ys, &zs);
if(stat != 3)
{
fprintf(stderr,"Error wrong data format in %s\n",ifilename);
exit(EXIT_FAILURE);
}
stat=sscanf( cbuf, "%lf %lf %lf", &xc, &yc, &zc);
if(stat != 3)
{
fprintf(stderr,"Error wrong data format in %s\n",cfilename);
exit(EXIT_FAILURE);
}
xout=xs-xc;
yout=ys-yc;
zout=zs-zc;
fprintf(ofile,"%lf %lf %lf\n", xout , yout , zout);
}
fprintf(stdout,"...done\nResults written to %s\n", ofilename);
(void)fclose(ifile);
(void)fclose(cfile);
(void)fclose(ofile);
return(0);
}
6 changes: 1 addition & 5 deletions src/helmert3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

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

#define VERS "1.0.0"
#include "helmert3d.h"

static size_t get_m_size(char *filename)
{
Expand Down
27 changes: 27 additions & 0 deletions src/helmert3d.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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.
*/

#ifndef HELMERT3D_H
#define HELMERT3D_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define VERS "1.0.1"
#define DEBUG 0

#endif // HELMERT3D_H
6 changes: 1 addition & 5 deletions src/helmparms3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "helmert3d.h"
#include "svdm.h"
#define VERS "1.0.0"
#define DEBUG 0

static void freematrix(size_t m, /*@only@*/ /*@out@*/ /*@null@*/ double ** u)
{
Expand Down

1 comment on commit 4a16f2e

@zvezdochiot
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Added utility for comparing the resulting coordinates.

Please sign in to comment.