This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool in_polygon(const point &p, point ps[], int len) | |
{ | |
int i, j = len - 1; | |
bool oddNodes = false; | |
for (i = 0; i < len; i++) { | |
if ((ps[i].y < p.y && ps[j].y >= p.y | |
|| ps[j].y < p.y && ps[i].y >= p.y) | |
&& (ps[i].x <= p.x || ps[j].x <= p.x)) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set up path movement | |
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; | |
pathAnimation.calculationMode = kCAAnimationPaced; | |
pathAnimation.fillMode = kCAFillModeForwards; | |
pathAnimation.removedOnCompletion = NO; | |
pathAnimation.repeatCount = INFINITY; | |
//pathAnimation.rotationMode = @"auto"; | |
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; | |
pathAnimation.duration = 5.0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard HEAD~2 # 取消当前版本之前的两次提交 | |
git push origin HEAD --force # 强制提交到远程版本库,从而删除之前的两次提交数据 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < output.rows; i++) | |
{ | |
uchar *out_data = output.ptr<uchar>(i); | |
for (int j = 0; j < output.cols; j++) | |
{ | |
double ox; | |
double oy; | |
//Calculate the old point(ox, oy) according to j, i | |
//Thus, find a function f:(j, i)->(ox, oy) to get the result like (ox, oy)=f(j, i) | |
int x1 = ox < 0 ? 0 : ox; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//normal1: a 3d double vector indicating the normal vector of line1 | |
//point1: a 3d double point indicating any point on line1 | |
//normal2: a 3d double vector indicating the normal vector of line2 | |
//point2: a 3d double point indicating any point on line2 | |
//nearest_point: a 3d double point as the nearest point between line1 and line2 | |
void nearest_point_between_two_lines( | |
const double *normal1, const double *point1, | |
const double *normal2, const double *point2, | |
double *nearest_point) | |
{ |
NewerOlder