liblashgame

Pathfinder and path decision making library for 2D tile game
git clone git://holbrook.no/liblashgame.git
Info | Log | Files | Refs

polarcartesian.c (632B)


      1 // polartocartesian 
      2 
      3 #include "../lash_game_standard.h"
      4 #include <string.h>
      5 #include <stdio.h>
      6 #include <stdlib.h>
      7 
      8 int main(int argc, char *argv[]) {
      9 	if (argc < 5) {
     10 		printf("Usage: %s radians radius src_x src_y\n", argv[0]);
     11 		return 1;
     12 	}
     13 	
     14 	float radians = atof(argv[1]);
     15 	float radius = atof(argv[2]);
     16 	int16_t src_x = atoi(argv[3]);
     17 	int16_t src_y = atoi(argv[4]);
     18 	int target_x = 0.f;
     19 	int target_y = 0.f;
     20 	
     21 	lash_polarToCartesian(radians, radius, src_x, src_y, &target_x, &target_y);
     22 	
     23 	printf("Src: x%d,y%d\nRadians: %f\nRadius: %f\nResult: x%d,y%d\n", src_x, src_y, radians, radius, target_x, target_y);
     24 	
     25 	return 0;
     26 }