Can anyone please help me out with this please?
[code C++]
(Global) Var Vector Intersect1, Intersect2;
Function Int FindSphereIntersection(Vector LineStart, Vector LineEnd, Vector SphereOrigin, Float SphereRadius)
{
//Math, math, math.
//Math, math, math.
//Math, math, math.
if (Line from LineStart to LineEnd doesnt intersect with Sphere)
Return 0;
if (Line from LineStart to LineEnd intersects with Sphere once)
{
Intersect1 = Intersect point;
Return 1;
}
if (Line from LineStart to LineEnd intersects with Sphere twice)
{
Intersect1 = Intersect point;
Intersect1 = Other intersect point;
Return 2;
}
}
[/code]
This sort of math is beyond my understanding unfortunately so any help would be appreciated thanks.
For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com
Point where a line segment intersects a sphere?
Point where a line segment intersects a sphere?
Finaly signed up, been a fan for years...
- Bleeder91[NL]
- OldUnreal Member
- Posts: 1058
- Joined: Sun Oct 04, 2009 7:22 pm
Re: Point where a line segment intersects a sphere?
I'm too tired to code it now but this might help:
https://www.scratchapixel.com/lessons/3 ... tersection
https://www.scratchapixel.com/lessons/3 ... tersection
Re: Point where a line segment intersects a sphere?
I've used this code for 2D sphere ray to sphere collision check, pretty sure it works just like that in 3D coordinates too:
Code: Select all
simulated function TraceActor( TDActor A, TR_TraceInfo T )
{
local float aa,b,c,radii;
local vector Dir;
Dir = T.Start - A.Location2D;
radii = A.CollisionSize.X + T.Extent.X;
// Simple circle overlap check.
c = (Dir Dot Dir) - Square(radii);
if( c= 0 && c
To help understand the values:
T.Start = trace start.
A.Location2D = sphere location.
A.CollisionSize.X = sphere radius.
T.Extent.X = ray trace sphere radius.
T.Dir = End-Start direction of raytrace.
T.SetTraceHit(,,);
As said it was originally only used for 2D traces, but it should work in 3D too.
(ಠ_ಠ)1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD
Re: Point where a line segment intersects a sphere?
Thank you both for your help!
I have a solution here: https://ut99.org/viewtopic.php?f=15&t=1 ... 22#p124822
I have a solution here: https://ut99.org/viewtopic.php?f=15&t=1 ... 22#p124822
Finaly signed up, been a fan for years...
-
- Similar Topics
- Replies
- Views
- Last post