- Joined
- Aug 5, 2014
- Messages
- 209
Hello, im struggling with this problem right now. Scoured the internet and didnt find any proper guide for this case, and dont know where to go with this question, and i remembered that usually on this site i can find help.
In my case i try to create function which give me a length of segment of intersection between a cylinder and segment with Lua.
Of course the game im making it for is Serious Sam 2017 fusion, not Warcraft 3, please pay close attention to this fact if this is matters, but at least language must be same.
Right now i take as reference this:
stackoverflow.com
And this:
Currently i've implemented this part:
local A - - cylinder start
local B - - cylinder end
local r - - cylinder radius
local Point - - line start
local PPoint - - line end
local Dir = PPoint - Point
local AB = B - A
local A0 = Point - A
local A0xAB = mthCrossV3(A0, AB)
local VxAB = mthCrossV3(Dir, AB)
local ab2 = mthDotV3f(AB, AB)
local a = mthDotV3f(VxAB, VxAB)
local b = 2 * mthDotV3f(VzAB, A0xAB)
local c = mthDotV3f(A0xAB, A0xAB)
local d = b * b - 4 * a *c
local t = (-(b) - mthSqrtF(d))
Of course i ported it to lua.
And i feel the "time" is what i need.
The result itself is somekind working, but it seems that despite having start and points the cylinder itself act like infinite, as i get reading of intersections beyond two points.
Also any check from stackoverflow cause this function to return no result at all, as some or even first check is not passed.
Please help, thank you in advance.
P. S: If i got the wrong section for my question, please relocate this thread.
In my case i try to create function which give me a length of segment of intersection between a cylinder and segment with Lua.
Of course the game im making it for is Serious Sam 2017 fusion, not Warcraft 3, please pay close attention to this fact if this is matters, but at least language must be same.
Right now i take as reference this:
Trying to optimize line vs cylinder intersection
My brain has been melting over a line segment-vs-cylinder intersection routine I've been working on. /// Line segment VS <cylinder> // - cylinder (A, B, r) (start point, end point, radius)...
And this:
Currently i've implemented this part:
local A - - cylinder start
local B - - cylinder end
local r - - cylinder radius
local Point - - line start
local PPoint - - line end
local Dir = PPoint - Point
local AB = B - A
local A0 = Point - A
local A0xAB = mthCrossV3(A0, AB)
local VxAB = mthCrossV3(Dir, AB)
local ab2 = mthDotV3f(AB, AB)
local a = mthDotV3f(VxAB, VxAB)
local b = 2 * mthDotV3f(VzAB, A0xAB)
local c = mthDotV3f(A0xAB, A0xAB)
local d = b * b - 4 * a *c
local t = (-(b) - mthSqrtF(d))
Of course i ported it to lua.
And i feel the "time" is what i need.
The result itself is somekind working, but it seems that despite having start and points the cylinder itself act like infinite, as i get reading of intersections beyond two points.
Also any check from stackoverflow cause this function to return no result at all, as some or even first check is not passed.
Please help, thank you in advance.
P. S: If i got the wrong section for my question, please relocate this thread.