char *ray_tos(ray r) { char buf[1024] = {0}; char *s1 = vec_tos(r.origin); char *s2 = vec_tos(r.direction); sprintf(buf,"ray(o:%s,dir:%s)",s1,s2); free(s1); free(s2); return strdup(buf); }
char *ray_tos(ray *r) { char buf[128]; int i; for (i=0; i<127; i++) buf[i] = '\0'; char *or = vec_tos(r->origin); char *dir= vec_tos(r->direction); sprintf(buf, "Origin: %s\nDirection: %s", or, dir); free(or); free(dir); return strdup(buf); }
/* outputs a camera in string format */ void camera_print(camera *c) { if (c == NULL) { fprintf(stderr, "%s\n", "camera_print: parameter is NULL."); exit(1); } printf("CAMERA - loc: %s, h: %u, w: %u - END CAMERA STRUCT\n", vec_tos(c->loc), c->h, c->w); return; }
char *sphere_tos(sphere *s) { char buf[128]; int i; for (i=0; i<127; i++) buf[i] = '\0'; char *cen = vec_tos(s->center); char *col= rgb_tos(s->color); sprintf(buf, "Center: %s\nRadius: %lf\nColor: %s", cen, s->radius, col); free(cen); free(col); return strdup(buf); }
void camera_print(camera* c){ char* s = vec_tos(c->loc); printf("Location: %s height: %u width: %u\n", s, c->h, c->w); free(s); }