~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/draw/paint/tv_line3.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 double  ipos_dist_seg();
 14 
 15 void    line3_draw(Tv * tv, Line3 * line)
 16 {
 17     if (line == NULL)
 18         return;
 19     tv_line3(tv, line->p1, line->p2);
 20 }
 21 
 22 void    line3_draw_directed(Tv * tv, Line3 * line, int direction)
 23 {
 24     Ipos    p1 = {Ipos_id};
 25     Ipos    p2 = {Ipos_id};
 26     Ipos    tv_proj3();
 27     float   ydir, xdir, mag;
 28     float   hl, hw;             /* head length and width */
 29 
 30     if (line == NULL)
 31         return;
 32 
 33     switch (direction)
 34     {
 35     case NEGATIVE:
 36         p2 = tv_proj3(tv, line->p1);
 37         p1 = tv_proj3(tv, line->p2);
 38         break;
 39     case POSITIVE:
 40     default:
 41         p1 = tv_proj3(tv, line->p1);
 42         p2 = tv_proj3(tv, line->p2);
 43         break;
 44     }
 45 
 46     if (p2.x == p1.x && p2.y == p1.y)
 47         return;
 48 
 49     tv_line(tv, p1, p2);
 50     xdir = (float)(p2.x - p1.x);
 51     ydir = (float)(p2.y - p1.y);
 52     mag = (float)sqrt(SQR(xdir) + SQR(ydir));
 53     xdir /= mag;
 54     ydir /= mag;
 55 
 56     hl = mag / 10;
 57     if (hl > 10)
 58         hl = (float)10.0;
 59     hw = hl / 3;
 60 
 61     p1.x = (int)(p2.x - hl * xdir);
 62     p1.y = (int)(p2.y - hl * ydir);
 63 
 64     tv_line(tv, ipos((int) (p1.x - ydir * hw), (int) (p1.y + xdir * hw)), p2);
 65     tv_line(tv, ipos((int) (p1.x + ydir * hw), (int) (p1.y - xdir * hw)), p2);
 66 }
 67 
 68 double  pick_line3_dist(Tv * tv, Ipos pos, Line3 * line)
 69 {
 70     Ipos    p1 = {Ipos_id};
 71     Ipos    p2 = {Ipos_id};
 72 
 73     p1 = tv_proj3(tv, line->p1);
 74     p2 = tv_proj3(tv, line->p2);
 75     return (ipos_dist_seg(pos, p1, p2));
 76 }
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.