libfvec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit aa9244083f5f600f400f101b8092e7c828434500
Author: Gitea <gitea@fake.local>
Date:   Tue, 18 Feb 2020 23:52:22 -0600

Initial version

Diffstat:
AREADME | 20++++++++++++++++++++
Afvec.c | 19+++++++++++++++++++
Afvec.h | 15+++++++++++++++
3 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,19 @@ +libfvec - The Fenris Vector Library +=================================== + +libfvec is a general purpose, double precision 3D vector library for C. It \ +handles all the essential vector operations. + +Building +-------- + +Portability +----------- + +Copyright +--------- + +None + +libfvec is free software. Feel free to modify and/or distribute it! +See the file COPYING for more details.+ \ No newline at end of file diff --git a/fvec.c b/fvec.c @@ -0,0 +1,19 @@ +double dotp(vec3 * u, vec3 * v) { + return (u->x * v->x) + (u->y * v->y) + (u->z * v->z); +} + +vec3 * crossp(vec3 * u, vec3 * v) { + vec3 * w = malloc(sizeof(*w)); + w->x = (u->y * v->z) - (u->z * v->y); + w->y = -((u->x * v->z) - (u->z * v->x)); + w->z = (u->x * v->y) - (u->y * v->x); + return w; +} + +vec3 * compose(vec3 * u, vec3 * v) { + vec3 * w = malloc(sizeof(*w)); + w->x = u->x + v->x; + w->y = u->y + v->y; + w->z = u->z + v->z; + return w; +} diff --git a/fvec.h b/fvec.h @@ -0,0 +1,15 @@ +#ifndef _FVEC +#define _FVEC + +typedef struct _fvec3 { + double x; + double y; + double z; +} vec3; + +vec3 * crossp(vec3 *, vec3 *); +double dotp(vec3 *, vec3 *); + +vec3 * compose(vec3 *, vec3 *); + +#endif