Skip to content

Instantly share code, notes, and snippets.

@slembcke
Created May 16, 2012 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slembcke/2712996 to your computer and use it in GitHub Desktop.
Save slembcke/2712996 to your computer and use it in GitHub Desktop.
#define CP_USE_DOUBLES 1
#if CP_USE_DOUBLES
/// Chipmunk's floating point type.
/// Can be reconfigured at compile time.
typedef double cpFloat;
#define cpfsqrt sqrt
#define cpfsin sin
#define cpfcos cos
#define cpfacos acos
#define cpfatan2 atan2
#define cpfmod fmod
#define cpfexp exp
#define cpfpow pow
#define cpffloor floor
#define cpfceil ceil
#else
typedef float cpFloat;
#define cpfsqrt sqrtf
#define cpfsin sinf
#define cpfcos cosf
#define cpfacos acosf
#define cpfatan2 atan2f
#define cpfmod fmodf
#define cpfexp expf
#define cpfpow powf
#define cpffloor floorf
#define cpfceil ceilf
#endif
typedef struct cpVect{cpFloat x,y;} cpVect;
static inline cpVect cpv(const cpFloat x, const cpFloat y)
{
cpVect v = {x, y};
return v;
}
cpVect
cpvforangle(const cpFloat a)
{
cpVect v = {cpfcos(a), cpfsin(a)};
return v;
}
## output
.globl _cpvforangle
.align 4, 0x90
_cpvforangle: ## @cpvforangle
Ltmp81:
.cfi_startproc
Lfunc_begin3:
.loc 1 55 0 ## /Users/slembcke/Development/ChipmunkPro/Chipmunk/xcode/../src/cpVect.c:55:0
## BB#0:
pushq %rbp
Ltmp82:
.cfi_def_cfa_offset 16
Ltmp83:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp84:
.cfi_def_cfa_register %rbp
##DEBUG_VALUE: cpvforangle:a <- XMM0+0
.loc 1 56 25 prologue_end ## /Users/slembcke/Development/ChipmunkPro/Chipmunk/xcode/../src/cpVect.c:56:25
Ltmp85:
popq %rbp
Ltmp86:
.loc 1 54 27 ## /Users/slembcke/Development/ChipmunkPro/Chipmunk/xcode/../src/cpVect.c:54:27
jmp _sin ## TAILCALL
Ltmp87:
Lfunc_end3:
Ltmp88:
.cfi_endproc
Leh_func_end3:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment