• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Get the lehgth of intersection between a segment and FINITE 3d cylinder. (lua)

Level 8
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:


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.
 
Back
Top