src/miscallenous.cpp

changeset 966
a834e43a57da
parent 962
a4b463a7ee82
child 968
4b93b7963456
equal deleted inserted replaced
965:d1b0aa40db91 966:a834e43a57da
107 // Snap the given coordinate value on the current grid's given axis. 107 // Snap the given coordinate value on the current grid's given axis.
108 // 108 //
109 double Grid::Snap (double value, const Grid::Config type) 109 double Grid::Snap (double value, const Grid::Config type)
110 { 110 {
111 double snapvalue = (type == Coordinate) ? *CurrentGrid().coordinateSnap : *CurrentGrid().angleSnap; 111 double snapvalue = (type == Coordinate) ? *CurrentGrid().coordinateSnap : *CurrentGrid().angleSnap;
112 double mult = floor (Abs<double> (value / snapvalue)); 112 double mult = floor (qAbs<double> (value / snapvalue));
113 double out = mult * snapvalue; 113 double out = mult * snapvalue;
114 114
115 if (Abs (value) - (mult * snapvalue) > snapvalue / 2) 115 if (qAbs (value) - (mult * snapvalue) > snapvalue / 2)
116 out += snapvalue; 116 out += snapvalue;
117 117
118 if (value < 0) 118 if (value < 0)
119 out = -out; 119 out = -out;
120 120

mercurial