五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

輪子:UE4中計(jì)算直線和圓的交點(diǎn)

2023-06-06 17:58 作者:小強(qiáng)強(qiáng)  | 我要投稿

UE4.18中只提供了判斷直線和圓是否相交的API(FMath::LineSphereIntersection),現(xiàn)在有個(gè)需求要求交點(diǎn),只能自己動(dòng)手寫了


TArray<FVector> LineSphereIntersection(const FVector& LineOrigin, const FVector& LineDir, const FVector& circleOrigin, float radius)?

{

????TArray<FVector> IntersectionPoints;

????// 求圓心到直線最近的點(diǎn)

????FVector CloestPoint = FMath::ClosestPointOnLine(LineOrigin, LineDir, circleOrigin);?

? ?// 圓心到直線的距離

???float dist = (CloestPoint - circleOrigin).Size();

? ?if(dist > radius)?

? ?{

? ? ? ?// 距離大于圓的半徑,沒有交點(diǎn)

? ?}

? ?else if(dist == radius)

? ?{

?? ? ? ?// 距離等于半徑,交點(diǎn)就是最近的點(diǎn)

?? ? ? ?IntersectionPoints.Add(ClosestPoint);

? ? }

? ?else

? ?{?

? ? ? ?// 距離小于半徑,交點(diǎn)有2個(gè)

?? ? ? ?// 斜邊邊長 = 半徑, 一條直角邊長 = 圓心到直線的距離

?? ? ? ?float HypotenuseLength = FMath::Sqrt(radius * radius - dist * dist);

? ? ? ?FVector Point1 = ClosestPoint + LineDir * HypotenuseLength;

? ? ? ?IntersectionPoints.Add(Point1);?

? ? ? ?FVector Point2 = ClosestPoint - LineDir * HypotenuseLength;?

? ? ? ?IntersectionPoints.Add(Point2);

? ? ?}

? ? ? ?return IntersectionPoints;

? }



為什么沒有代碼格式的排版……

輪子:UE4中計(jì)算直線和圓的交點(diǎn)的評(píng)論 (共 條)

分享到微博請遵守國家法律
盐山县| 祁阳县| 微博| 霍山县| 如皋市| 囊谦县| 滕州市| 开鲁县| 张北县| 甘谷县| 新丰县| 栾城县| 民乐县| 东山县| 建湖县| 玉山县| 定远县| 墨竹工卡县| 讷河市| 凤阳县| 习水县| 曲麻莱县| 余干县| 洛川县| 河池市| 永城市| 黄梅县| 元谋县| 鸡泽县| 武强县| 安康市| 阳曲县| 太白县| 炉霍县| 台江县| 都匀市| 白朗县| 华蓥市| 罗源县| 武清区| 云梦县|