diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-04-08 22:26:04 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-04-08 22:26:04 +0000 |
commit | 97d9b60f0fff735bace4653f3b321592ba4ed1cc (patch) | |
tree | 6180a064a135b8084c1dad31b327708c0717b9cf | |
parent | adb94a2b009608f7b1a1f47ca99235fb6c938593 (diff) | |
download | dimension-97d9b60f0fff735bace4653f3b321592ba4ed1cc.tar.xz |
Remove non-portable inline functions.
-rw-r--r-- | libdimension/Makefile.am | 2 | ||||
-rw-r--r-- | libdimension/dimension.h | 4 | ||||
-rw-r--r-- | libdimension/dimension/geometry.h | 57 | ||||
-rw-r--r-- | libdimension/geometry.c (renamed from libdimension/inlines.c) | 61 |
4 files changed, 71 insertions, 53 deletions
diff --git a/libdimension/Makefile.am b/libdimension/Makefile.am index 9338b38..69bcbb3 100644 --- a/libdimension/Makefile.am +++ b/libdimension/Makefile.am @@ -21,5 +21,5 @@ nobase_include_HEADERS = dimension.h dimension/geometry.h dimension/color.h dime lib_LTLIBRARIES = libdimension.la -libdimension_la_SOURCES = dimension.h dimension/geometry.h dimension/color.h dimension/canvas.h canvas.c color.c inlines.c +libdimension_la_SOURCES = dimension.h dimension/geometry.h dimension/color.h dimension/canvas.h canvas.c color.c geometry.c libdimension_la_LDFLAGS = -version-info 0:0:0 diff --git a/libdimension/dimension.h b/libdimension/dimension.h index c52ae31..558c9ed 100644 --- a/libdimension/dimension.h +++ b/libdimension/dimension.h @@ -28,10 +28,6 @@ extern "C" { #endif -#ifndef DMNSN_INLINE -#define DMNSN_INLINE extern inline -#endif - #include <dimension/geometry.h> #include <dimension/color.h> #include <dimension/canvas.h> diff --git a/libdimension/dimension/geometry.h b/libdimension/dimension/geometry.h index 11a6daf..6493407 100644 --- a/libdimension/dimension/geometry.h +++ b/libdimension/dimension/geometry.h @@ -31,50 +31,17 @@ typedef struct { dmnsn_scalar x, y, z; } dmnsn_vector; /* Vector arithmetic */ -DMNSN_INLINE dmnsn_vector -dmnsn_vector_construct(dmnsn_scalar x, dmnsn_scalar y, dmnsn_scalar z) -{ - dmnsn_vector v = { .x = x, .y = y, .z = z }; - return v; -} +dmnsn_vector dmnsn_vector_construct(dmnsn_scalar x, + dmnsn_scalar y, + dmnsn_scalar z); -DMNSN_INLINE dmnsn_vector -dmnsn_vector_add(dmnsn_vector lhs, dmnsn_vector rhs) -{ - return dmnsn_vector_construct(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); -} +dmnsn_vector dmnsn_vector_add(dmnsn_vector lhs, dmnsn_vector rhs); +dmnsn_vector dmnsn_vector_sub(dmnsn_vector lhs, dmnsn_vector rhs); +dmnsn_vector dmnsn_vector_mul(dmnsn_scalar lhs, dmnsn_vector rhs); +dmnsn_vector dmnsn_vector_div(dmnsn_vector lhs, dmnsn_scalar rhs); -DMNSN_INLINE dmnsn_vector -dmnsn_vector_sub(dmnsn_vector lhs, dmnsn_vector rhs) -{ - return dmnsn_vector_construct(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); -} - -DMNSN_INLINE dmnsn_vector -dmnsn_vector_mul(dmnsn_scalar lhs, dmnsn_vector rhs) -{ - return dmnsn_vector_construct(lhs*rhs.x, lhs*rhs.y, lhs*rhs.z); -} - -DMNSN_INLINE dmnsn_vector -dmnsn_vector_div(dmnsn_vector lhs, dmnsn_scalar rhs) -{ - return dmnsn_vector_construct(lhs.x/rhs, lhs.y/rhs, lhs.z/rhs); -} - -DMNSN_INLINE dmnsn_scalar -dmnsn_vector_dot(dmnsn_vector lhs, dmnsn_vector rhs) -{ - return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z; -} - -DMNSN_INLINE dmnsn_vector -dmnsn_vector_cross(dmnsn_vector lhs, dmnsn_vector rhs) -{ - return dmnsn_vector_construct(lhs.y*rhs.z - lhs.z*rhs.y, - lhs.z*rhs.x - lhs.x*rhs.z, - lhs.x*rhs.y - lhs.y*rhs.x); -} +dmnsn_scalar dmnsn_vector_dot(dmnsn_vector lhs, dmnsn_vector rhs); +dmnsn_vector dmnsn_vector_cross(dmnsn_vector lhs, dmnsn_vector rhs); /* A line, or ray. */ typedef struct { @@ -83,10 +50,6 @@ typedef struct { } dmnsn_line; /* A point on a line, defined by x0 + t*n */ -DMNSN_INLINE dmnsn_vector -dmnsn_line_point(dmnsn_line l, dmnsn_scalar t) -{ - return dmnsn_vector_add(l.x0, dmnsn_vector_mul(t, l.n)); -} +dmnsn_vector dmnsn_line_point(dmnsn_line l, dmnsn_scalar t); #endif /* DIMENSION_GEOMETRY_H */ diff --git a/libdimension/inlines.c b/libdimension/geometry.c index 51348fa..c6909f4 100644 --- a/libdimension/inlines.c +++ b/libdimension/geometry.c @@ -18,5 +18,64 @@ * <http://www.gnu.org/licenses/>. * *************************************************************************/ -#define DMNSN_INLINE #include "dimension.h" + +dmnsn_vector +dmnsn_vector_construct(dmnsn_scalar x, dmnsn_scalar y, dmnsn_scalar z) +{ + dmnsn_vector v = { .x = x, .y = y, .z = z }; + return v; +} + +dmnsn_vector +dmnsn_vector_add(dmnsn_vector lhs, dmnsn_vector rhs) +{ + dmnsn_vector v = { .x = lhs.x + rhs.x, + .y = lhs.y + rhs.y, + .z = lhs.z + rhs.z }; + return v; +} + +dmnsn_vector +dmnsn_vector_sub(dmnsn_vector lhs, dmnsn_vector rhs) +{ + dmnsn_vector v = { .x = lhs.x - rhs.x, + .y = lhs.y - rhs.y, + .z = lhs.z - rhs.z }; + return v; +} + +dmnsn_vector +dmnsn_vector_mul(dmnsn_scalar lhs, dmnsn_vector rhs) +{ + dmnsn_vector v = { .x = lhs*rhs.x, .y = lhs*rhs.y, .z = lhs*rhs.z }; + return v; +} + +dmnsn_vector +dmnsn_vector_div(dmnsn_vector lhs, dmnsn_scalar rhs) +{ + dmnsn_vector v = { .x = lhs.x/rhs, .y = lhs.y/rhs, .z = lhs.z/rhs }; + return v; +} + +dmnsn_scalar +dmnsn_vector_dot(dmnsn_vector lhs, dmnsn_vector rhs) +{ + return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z; +} + +dmnsn_vector +dmnsn_vector_cross(dmnsn_vector lhs, dmnsn_vector rhs) +{ + dmnsn_vector v = { .x = lhs.y*rhs.z - lhs.z*rhs.y, + .y = lhs.z*rhs.x - lhs.x*rhs.z, + .z = lhs.x*rhs.y - lhs.y*rhs.x }; + return v; +} + +dmnsn_vector +dmnsn_line_point(dmnsn_line l, dmnsn_scalar t) +{ + return dmnsn_vector_add(l.x0, dmnsn_vector_mul(t, l.n)); +} |