五月天青色头像情侣网名,国产亚洲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)論 (共 條)

分享到微博請遵守國家法律
天镇县| 吉安市| 板桥市| 辽源市| 镇康县| 泽库县| 天全县| 绥阳县| 南木林县| 梁河县| 聂拉木县| 邢台县| 大埔县| 长兴县| 新民市| 嘉禾县| 大理市| 仪征市| 镇安县| 平阴县| 辛集市| 钟祥市| 于都县| 永新县| 林州市| 新泰市| 林芝县| 江永县| 富源县| 中山市| 盘锦市| 嘉定区| 调兵山市| 八宿县| 贵南县| 东辽县| 中卫市| 北京市| 江永县| 克什克腾旗| 西贡区|