Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c4cb382
C-API: add additive inverse to offsets when applying mods
CarawaySeed42 May 31, 2026
079fc1d
c-api: apply offset in designated function
CarawaySeed42 Jun 9, 2026
431a950
c-api: add change global origin function to api
CarawaySeed42 Jun 9, 2026
57b3e18
c-api: add heading offset to origin setter
CarawaySeed42 Jun 9, 2026
3fdbc26
c-api: add global origin getter
CarawaySeed42 Jun 10, 2026
0fd7fbb
c-api: add xyz2enh and enh2xyz evaluation
CarawaySeed42 Jun 10, 2026
10ac8f0
c-api: always offset channelRefZ and not Z
CarawaySeed42 Jun 11, 2026
170a6bb
c-api: update makefile to use crgEvalenh.c
CarawaySeed42 Jun 11, 2026
db01bce
c-api: precalculate sin and cos of poff
CarawaySeed42 Jun 14, 2026
5e70584
c-api: remove condition branch in offset z function
CarawaySeed42 Jun 15, 2026
39138a0
c-api: fix global offset from rotation
CarawaySeed42 Jul 1, 2026
cdd0ed6
Merge branch 'c-api-mods-retain-global-position' into c-api-add-set-o…
CarawaySeed42 Jul 1, 2026
d37e43c
c-api: adapt global origin setter to offset change
CarawaySeed42 Jul 1, 2026
713338a
c-api: change loop variable type from int to size_t
CarawaySeed42 Jul 1, 2026
1350f57
c-api: rename global origin setter function
CarawaySeed42 Jul 1, 2026
7ab0d1c
c-api: remove eval enh functions with dataset id argument
CarawaySeed42 Jul 3, 2026
c978f87
c-api: remove global origin setter and getter
CarawaySeed42 Sep 8, 2026
4d4c158
Merge branch 'master' into c-api-add-xyz2enh-and-vice-versa
CarawaySeed42 Sep 8, 2026
e23939d
Merge branch 'c-api-add-xyz2enh-and-vice-versa' into c-api-add-set-or…
CarawaySeed42 Sep 8, 2026
0c6f50e
c-api: add global origin setter and getter again
CarawaySeed42 Sep 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions c-api/baselib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif()
# Source files
set(OPENCRG_SOURCES
src/crgContactPoint.c
src/crgEvalenh.c
src/crgEvalpk.c
src/crgEvaluv2xy.c
src/crgEvalxy2uv.c
Expand Down
54 changes: 53 additions & 1 deletion c-api/baselib/inc/crgBaseLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@
#endif
/* ====== TYPE DEFINITIONS ====== */

/* ====== METHODS in crgMgr.c ====== */
#ifdef __cplusplus
extern "C"
{
#endif

/* ====== METHODS in crgMgr.c ====== */
/**
* destroy the data of the given data set
* @param dataSetId identifier of the applicable dataset
Expand Down Expand Up @@ -298,6 +299,30 @@ extern "C"
*/
extern void crgDataSetOptionSetDefault( int dataSetId );

/**
* set the global offset values for a data set;
* the local coordinates are changed accordingly, so that no shift
* of evaluated global coordinates will occur
* @param dataSetId identifier of the applicable dataset
* @param xoff new x offset
* @param yoff new y offset
* @param zoff new z offset
* @param poff new p angle offset
* @return 1 if successful, otherwise 0
*/
extern int crgDataSetSetGlobalOrigin(int dataSetId, double xoff, double yoff, double zoff, double poff);

/**
* get the global offset values for a data set;
* @param dataSetId identifier of the applicable dataset
* @param xoff x offset return value
* @param yoff y offset return value
* @param zoff z offset return value
* @param poff p angle offset return value
* @return 1 if successful, otherwise 0
*/
extern int crgDataSetGetGlobalOrigin(int dataSetId, double* xoff, double* yoff, double* zoff, double* poff);

/**
* release all data held by the crg library
*/
Expand Down Expand Up @@ -540,6 +565,33 @@ extern "C"
*/
extern int crgEvalxy2pk( int cpId, double x, double y, double* phi, double* curv );

/* ====== METHODS in crgEvalenh.c ====== */
/**
* convert a given local (x,y,z) position into the corresponding global (e,n,h) position
* @param cpId id of the contact point that is used for the query
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param e e coordinate
* @param n n coordinate
* @param h h coordinate
* @return 1 if successful, otherwise 0
*/
extern int crgEvalxyz2enh( int cpId, double x, double y, double z, double* e, double* n, double* h );

/**
* convert a given global (e,n,h) position into the corresponding local (x,y,z) position
* @param cpId id of the contact point that is used for the query
* @param e e coordinate
* @param n n coordinate
* @param h h coordinate
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @return 1 if successful, otherwise 0
*/
extern int crgEvalenh2xyz( int cpId, double e, double n, double h, double* x, double* y, double* z );

/* ====== METHODS in crgPortability.c ====== */
/**
* print a message with a defined criticality level
Expand Down
29 changes: 29 additions & 0 deletions c-api/baselib/inc/crgBaseLibPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ typedef struct
double phiFirstCos; /* cosine of first phi value [-] */
double phiLastSin; /* sine of last phi value [-] */
double phiLastCos; /* cosine of last phi value [-] */
double phiOffSin; /* sine of phi offset value [-] */
double phiOffCos; /* cosine of phi offset value [-] */
} CrgUtilityStruct;

/**
Expand Down Expand Up @@ -694,6 +696,33 @@ extern int mCrgBigEndian; /* endian-ness of machine */
*/
extern int crgDataEvaluv2pk( const CrgDataStruct *crgData, const CrgOptionsStruct* optionList, double u, double v, double* phi, double* curv );

/* ====== METHODS in crgEvalenh.c ====== */
/**
* convert a given local (x,y,z) position into the corresponding global (e,n,h) position
* @param crgData pointer to data set which holds the data
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param e e coordinate
* @param n n coordinate
* @param h h coordinate
* @return 1 if successful, otherwise 0
*/
extern int crgDataEvalxyz2enh( const CrgDataStruct* crgData, double x, double y, double z, double* e, double* n, double* h );

/**
* convert a given global (e,n,h) position into the corresponding local (x,y,z) position
* @param crgData pointer to data set which holds the data
* @param e e coordinate
* @param n n coordinate
* @param h h coordinate
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @return 1 if successful, otherwise 0
*/
extern int crgDataEvalenh2xyz( const CrgDataStruct* crgData, double e, double n, double h, double* x, double* y, double* z );

/* ====== METHODS in crgPortability.c ====== */
/**
* set the maximum level of messages that will be handled,
Expand Down
1 change: 1 addition & 0 deletions c-api/baselib/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ SOURCES = \
crgEvaluv2xy.c \
crgEvalz.c \
crgEvalpk.c \
crgEvalenh.c \
crgLoader.c \
crgOptionMgmt.c \
crgPortability.c
Expand Down
110 changes: 110 additions & 0 deletions c-api/baselib/src/crgEvalenh.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/* ===================================================
* convert a xyz to enh coordinates and vice versa
* ---------------------------------------------------
*
* See the NOTICE file distributed with this work regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* More Information on ASAM OpenCRG can be found here:
* https://www.asam.net/standards/detail/opencrg/
*
*/
/* ====== INCLUSIONS ====== */
#include "crgBaseLibPrivate.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

/* ====== DEFINITIONS ====== */

/* ====== TYPE DEFINITIONS ====== */

/* ====== LOCAL METHODS ====== */

/* ====== IMPLEMENTATION ====== */
int
crgEvalxyz2enh( int cpId, double x, double y, double z, double* e, double* n, double* h)
{
const CrgContactPointStruct* cp;

if ( !( cp = crgContactPointGetFromId( cpId ) ) )
return 0;

return crgDataEvalxyz2enh(cp->crgData, x, y, z, e, n, h);
}

int
crgDataEvalxyz2enh( const CrgDataStruct *crgData, double x, double y, double z, double* e, double* n, double* h )
{
if (!crgData)
return 0;

double xbeg = crgData->channelX.info.first;
double ybeg = crgData->channelY.info.first;

double ps = crgData->util.phiOffSin;
double pc = crgData->util.phiOffCos;

/* --- rotate around(xbeg, ybeg) --- */
double dx = x - xbeg;
double dy = y - ybeg;

*e = xbeg + dx * pc - dy * ps;
*n = ybeg + dx * ps + dy * pc;
*h = z;

/* --- translate --- */
*e += crgData->channelX.info.offset;
*n += crgData->channelY.info.offset;
*h += crgData->channelRefZ.info.offset;

return 1;
}

int
crgEvalenh2xyz( int cpId, double e, double n, double h, double* x, double* y, double* z )
{
const CrgContactPointStruct* cp;

if (!(cp = crgContactPointGetFromId(cpId)))
return 0;

return crgDataEvalenh2xyz(cp->crgData, e, n, h, x, y, z);
}

int
crgDataEvalenh2xyz( const CrgDataStruct* crgData, double e, double n, double h, double* x, double* y, double* z )
{
if (!crgData)
return 0;

double xbeg = crgData->channelX.info.first;
double ybeg = crgData->channelY.info.first;

double ps = crgData->util.phiOffSin;
double pc = crgData->util.phiOffCos;

/* --- translate --- */
*x = e - crgData->channelX.info.offset;
*y = n - crgData->channelY.info.offset;
*z = h - crgData->channelRefZ.info.offset;

/* --- rotate around(xbeg, ybeg) --- */
double dx = *x - xbeg;
double dy = *y - ybeg;
*x = xbeg + dx * pc + dy * ps;
*y = ybeg - dx * ps + dy * pc;

return 1;
}
Loading