1 /**@(#)
2 **/
3 #include <math.h>
4 #include <tina/sys.h>
5 #include <tina/math.h>
6 #include <tina/mathfuncs.h>
7 #include <tina/vision.h>
8 #include <tina/tv.h>
9 #include <tina/draw.h>
10 #include <tina/drawfuncs.h>
11 #include <tina/tvfuncs.h>
12
13 static void tv_polygon3(Tv * tv, Vec3 centre, double radius, Vec3 normal, int sides)
14 {
15 int i;
16 double dtheta = TWOPI / sides;
17 double x, y, theta;
18 Vec3 ex = {Vec3_id};
19 Vec3 ey = {Vec3_id};
20 Vec3 ez = {Vec3_id};
21 Vec3 p = {Vec3_id};
22 Vec3 q = {Vec3_id};
23
24 vec3_basis(normal, tv->ey3, &ex, &ey, &ez);
25 ex = vec3_times(radius, ex);
26 ey = vec3_times(radius, ey);
27 p = vec3_sum(centre, ey);
28 for (i = 1; i <= sides; i++)
29 {
30 theta = i * dtheta;
31 x = sin(theta);
32 y = cos(theta);
33 q = vec3_sum3(centre, vec3_times(x, ex), vec3_times(y, ey));
34 tv_line3(tv, p, q);
35 p = q;
36 }
37 }
38
39 void plane_draw(Tv * tv, Plane * plane)
40 {
41 double radius;
42
43 if (tv == NULL || plane == NULL)
44 return;
45
46 radius = tv->width / (32.0 * tv->scalex);
47 tv_polygon3(tv, plane->p, radius, plane->n, 5);
48 }
49
50 void plane_list_draw(Tv * tv, List * list)
51 {
52 List *ptr;
53
54 for (ptr = list; ptr != NULL; ptr = ptr->next)
55 {
56 Plane *plane = (Plane *) ptr->to;
57
58 plane_draw(tv, plane);
59 }
60 }
61
62 double pick_plane_dist(Tv * tv, Ipos pos, Plane * plane)
63 {
64 Ipos p = {Ipos_id};
65
66 p = tv_proj3(tv, plane->p);
67 return (ipos_dist(pos, p));
68 }
69
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.