Blender V2.61 - r43446

Basic.c

Go to the documentation of this file.
00001 
00028 #include "Basic.h"
00029 
00030 int min_i(int a, int b) { 
00031     return (a<b)?a:b; 
00032 }
00033 int max_i(int a, int b) {
00034     return (b<a)?a:b; 
00035 }
00036 int clamp_i(int val, int min, int max) { 
00037     return min_i(max_i(val, min), max);
00038 }
00039 
00040 float min_f(float a, float b) { 
00041     return (a<b)?a:b; 
00042 }
00043 float max_f(float a, float b) { 
00044     return (b<a)?a:b; 
00045 }
00046 float clamp_f(float val, float min, float max) { 
00047     return min_f(max_f(val, min), max);
00048 }
00049 
00050 void rect_copy(int dst[2][2], int src[2][2]) {
00051     dst[0][0]= src[0][0], dst[0][1]= src[0][1];
00052     dst[1][0]= src[1][0], dst[1][1]= src[1][1];
00053 }
00054 int rect_contains_pt(int rect[2][2], int pt[2]){
00055     return ((rect[0][0] <= pt[0] && pt[0] <= rect[1][0]) &&
00056             (rect[0][1] <= pt[1] && pt[1] <= rect[1][1]));
00057 }
00058 int rect_width(int rect[2][2]) {
00059     return (rect[1][0]-rect[0][0]);
00060 }
00061 int rect_height(int rect[2][2]) {
00062     return (rect[1][1]-rect[0][1]);
00063 }