Changeset 341

Show
Ignore:
Timestamp:
03/19/07 02:05:55 (1 year ago)
Author:
cweider2
Message:

Generators: clipping for points >SRT_MAX

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZ3DTorus.m

    r340 r341  
    2424        if(self) 
    2525        { 
    26         R = 2; 
    27         r = .75; 
    28          
    29         A = 1; 
    30         a = 1; 
    31          
    32         w = 25; 
    33          
    34         xs = 10; 
    35         ys = 33; 
    36         zs = 27; 
     26               R = 2; 
     27               r = .75; 
     28                
     29               A = 1; 
     30               a = 1; 
     31                
     32               w = 25; 
     33                
     34               xs = 10; 
     35               ys = 33; 
     36               zs = 27; 
    3737        } 
    3838        return self; 
     
    6767                float y2 = y1*cosf(zrot)+x1*sinf(zrot); 
    6868                 
    69                 points[p].x = (unsigned short)((x2/(z2+4.9))*32767); 
    70                 points[p].y = (unsigned short)((y2/(z2+4.9))*32767); 
     69                points[p].x = fmin((x2/(z2+4.9))*32767, 32767.); 
     70                points[p].y = fmin((y2/(z2+4.9))*32767, 32767.); 
    7171 
    7272                points[p].r = points[p].g = points[p].b = points[p].i = 0xFF; 
  • trunk/LaserLine_2.0/Src/Sequencing/Generators/LZSinewave.m

    r333 r341  
    1414- (id)init 
    1515  { 
    16          self = [super init]; 
    17          if(self) 
    18                
    19                freq_x = 1; 
    20                freq_y = 2.9955; 
    21                
    22          return self; 
     16  self = [super init]; 
     17  if(self) 
     18       
     19        freq_x = 1; 
     20        freq_y = 2.9955; 
     21       
     22  return self; 
    2323  } 
    2424 
     
    2626- (RawFrame)renderAtPosition:(float)position 
    2727  { 
    28          struct timeval time; 
    29          gettimeofday(&time,NULL); 
    30           
    31          unsigned pointCount = 1000; 
    32          RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 
    33          RawFrame frame = {points, pointCount}; 
    34           
    35          float t = (time.tv_sec + time.tv_usec/1000000)/10000*position; 
    36           
    37          unsigned i; 
    38          for(i = 0; i < pointCount; i++) 
    39                
    40                float t_p = (i/(float)pointCount)*2*3.14159*5+t; 
    41                 
    42                points[i].x = cos(freq_x*t_p)*32767; 
    43                points[i].y = sin(freq_y*t_p)*32767; 
    44                 
    45                points[i].r = 0xFF*i/pointCount; 
    46                points[i].g = 0xFF*i/pointCount; 
    47                points[i].b = 0xFF*i/pointCount; 
    48                 
    49                points[i].r = 0xFF; 
    50                points[i].g = 0xFF; 
    51                points[i].b = 0xFF; 
    52                
    53           
    54          return frame; 
     28  struct timeval time; 
     29  gettimeofday(&time,NULL); 
     30   
     31  unsigned pointCount = 1000; 
     32  RawPoint *points = malloc(sizeof(RawPoint)*pointCount); 
     33  RawFrame frame = {points, pointCount}; 
     34   
     35  float t = (time.tv_sec + time.tv_usec/1000000)/10000*position; 
     36   
     37  unsigned i; 
     38  for(i = 0; i < pointCount; i++) 
     39       
     40        float t_p = (i/(float)pointCount)*2*3.14159*5+t; 
     41         
     42        points[i].x = cos(freq_x*t_p)*32767; 
     43        points[i].y = sin(freq_y*t_p)*32767; 
     44         
     45        points[i].r = 0xFF*i/pointCount; 
     46        points[i].g = 0xFF*i/pointCount; 
     47        points[i].b = 0xFF*i/pointCount; 
     48         
     49        points[i].r = 0xFF; 
     50        points[i].g = 0xFF; 
     51        points[i].b = 0xFF; 
     52       
     53   
     54  return frame; 
    5555  } 
    5656