Skip to content

Instantly share code, notes, and snippets.

View BichengLUO's full-sized avatar
👨‍💻
Work at Google

Bicheng Luo BichengLUO

👨‍💻
Work at Google
View GitHub Profile
@BichengLUO
BichengLUO / In-polygon.cpp
Created September 21, 2015 11:42
In-polygon test
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))
{
@BichengLUO
BichengLUO / animate_round_path.mm
Created February 12, 2015 07:54
UIView animation along a round path
// 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;
@BichengLUO
BichengLUO / Git_Delete_Push
Created February 1, 2015 17:10
Git强制删除提交到远程版本库的数据与版本记录
git reset --hard HEAD~2 # 取消当前版本之前的两次提交
git push origin HEAD --force # 强制提交到远程版本库,从而删除之前的两次提交数据
@BichengLUO
BichengLUO / Bilinear_Interpolation.cpp
Created January 29, 2015 06:53
Bilinear Interpolation
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;
@BichengLUO
BichengLUO / nearest_point_between_two_lines.cpp
Last active January 23, 2023 22:31
Nearest point between two lines
//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)
{