//线段交集点计算
FVector CheckCollision5(FVector a, FVector a1, FVector b, FVector b1) { FVector
base = b1 - b; double d1 = FMath::Abs(FVector::CrossProduct(base, a - b).Size()); double d2 = FMath::Abs(FVector::CrossProduct(base, a1 - b).Size()); double t = d1 / (d1 + d2); FVector temp = (a1 - a)*t; return a + temp; }

判断点有没有存在凸面形状中

bool IsContansPoint1(FVector pt, TArray<FVector> arr)
{
    int i, j;
    bool c = false;
    int nverts = arr.Num();
    for (i = 0, j = nverts - 1; i < nverts; j = i++)
    {
        FVector vi = arr[i];
        FVector vj = arr[j];
        if (((vi.Y > pt.Y) != (vj.Y > pt.Y)) &&
            (pt.X < (vj.X - vi.X) * (pt.Y - vi.Y) / (vj.Y - vi.Y) + vi.X))
            c = !c;
    }
    return c;
    
}

以(x0,y0)为旋转中心点,
已经知旋转前点的位置(x1,y1)和旋转的角度a,求旋转后点的新位置(x2,y2)

如果是逆时针旋转:
x2 = (x1 - x0) * cosa - (y1 - y0) * sina + x0
y2 = (y1 - y0) * cosa + (x1 - x0) * sina + y0
如果是顺时针旋转:
x2 = (x1 - x0) * cosa + (y1 - y0) * sina + x0
y2 = (y1 - y0) * cosa - (x1 - x0) * sina + y0

 

posted on 2020-04-16 17:22  jackdesk  阅读(383)  评论(0编辑  收藏  举报