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

分享到微博請遵守國家法律
长子县| 无为县| 潞城市| 全椒县| 仲巴县| 司法| 陈巴尔虎旗| 永嘉县| 三穗县| 南昌市| 靖远县| 泾川县| 旌德县| 望谟县| 翁牛特旗| 拜泉县| 麻城市| 宜宾县| 中阳县| 唐海县| 石景山区| 深泽县| 库车县| 奈曼旗| 饶阳县| 静海县| 通渭县| 徐水县| 庆阳市| 通道| 海盐县| 新建县| 文山县| 康乐县| 陵水| 手游| 邹平县| 怀集县| 达孜县| 西昌市| 阳东县|