Skip to content

Commit

Permalink
Factorized: Ray intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdvideo1234 committed Apr 13, 2018
1 parent d1a2595 commit 0ced532
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ local asmlib = trackasmlib

------ CONFIGURE ASMLIB ------
asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","5.437")
asmlib.SetOpVar("TOOL_VERSION","5.438")
asmlib.SetIndexes("V",1,2,3)
asmlib.SetIndexes("A",1,2,3)
asmlib.SetIndexes("S",4,5,6,7)
Expand Down
21 changes: 9 additions & 12 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3295,27 +3295,24 @@ local function IntersectRay(vO1, vD1, vO2, vD2)
return StatusLog(nil,"IntersectRay: First ray undefined") end
local d2 = vD2:GetNormalized(); if(d2:Length() == 0) then
return StatusLog(nil,"IntersectRay: Second ray undefined") end
local dx = d1:Cross(d2)
local dn, oo = (dx:Length())^2, (vO2 - vO1)
if(dn < GetOpVar("EPSILON_ZERO")) then
local dx, oo = d1:Cross(d2), (vO2 - vO1)
local dn = (dx:Length())^2; if(dn < GetOpVar("EPSILON_ZERO")) then
return StatusLog(nil,"IntersectRay: Rays parallel") end
local f1 = DeterminantVector(oo,d2,dx) / dn
local f2 = DeterminantVector(oo,d1,dx) / dn
local x1, x2 = (vO1 + f1*d1), (vO2 + f2*d2)
local f1 = DeterminantVector(oo, d2, dx) / dn
local f2 = DeterminantVector(oo, d1, dx) / dn
local x1, x2 = (vO1 + f1 * d1), (vO2 + f2 * d2)
local xx = (x2 - x1); xx:Mul(0.5); xx:Add(x1)
return f1, f2, x1, x2, xx
end

local function IntersectRayParallel(vO1, vD1, vO2, vD2)
local d1 = vD1:GetNormalized()
if(d1:Length() == 0) then
local d1 = vD1:GetNormalized(); if(d1:Length() == 0) then
return StatusLog(nil,"IntersectRayParallel: First ray undefined") end
local d2 = vD2:GetNormalized()
if(d2:Length() == 0) then
local d2 = vD2:GetNormalized(); if(d2:Length() == 0) then
return StatusLog(nil,"IntersectRayParallel: Second ray undefined") end
local len = (vO2 - vO1):Length()
local len = (vO2 - vO1):Length()
local f1, f2 = (len / 2), (len / 2)
local x1, x2 = (vO1 + d1*f1), (vO2 + d2*f2)
local x1, x2 = (vO1 + f1 * d1), (vO2 + f2 * d2)
local xx = (x2 - x1); xx:Mul(0.5); xx:Add(x1)
return f1, f2, x1, x2, xx
end
Expand Down
20 changes: 10 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ Also, another great achievement progress is in place, so 10x guys for
Here is the list of all the people helped me maintain this project by answering my questions
about their track packs or in some other way. It is possible that missed someone, so please excuse me:
* [Ron Thunderr](https://steamcommunity.com/profiles/76561198121926395)
* [Magnum](http://steamcommunity.com/profiles/76561198004847743)
* [SligWolf](http://steamcommunity.com/profiles/76561198010984952)
* [Qwertyaaa](http://steamcommunity.com/profiles/76561198033658330)
* [Magnum](https://steamcommunity.com/profiles/76561198004847743)
* [SligWolf](https://steamcommunity.com/profiles/76561198010984952)
* [Qwertyaaa](https://steamcommunity.com/profiles/76561198033658330)
* [Mr. Train](https://steamcommunity.com/profiles/76561198041277955)
* [Shinji85](http://steamcommunity.com/profiles/76561197962603247)
* [StevenTechno](http://steamcommunity.com/profiles/76561198006216679)
* [Shinji85](https://steamcommunity.com/profiles/76561197962603247)
* [StevenTechno](https://steamcommunity.com/profiles/76561198006216679)
* [Battleship](https://steamcommunity.com/profiles/76561198170859437)
* [CalocoDoesGames](https://steamcommunity.com/profiles/76561198059235055)
* [Dat-Mudkip](http://steamcommunity.com/profiles/76561198074186688)
* [AlexCookie](http://steamcommunity.com/profiles/76561198143297186)
* [Grocel](http://steamcommunity.com/profiles/76561197970000386)
* [Dat-Mudkip](https://steamcommunity.com/profiles/76561198074186688)
* [AlexCookie](https://steamcommunity.com/profiles/76561198143297186)
* [Grocel](https://steamcommunity.com/profiles/76561197970000386)
* [Puppyjaws](https://steamcommunity.com/profiles/76561198146226478)
* [Bullseye SBT](http://steamcommunity.com/profiles/76561198082120871)
* [AlexALX](http://steamcommunity.com/profiles/76561198049628741)
* [Bullseye SBT](https://steamcommunity.com/profiles/76561198082120871)
* [AlexALX](https://steamcommunity.com/profiles/76561198049628741)
* [Gedo789](https://github.com/Gedo789)
* Arbitor 90
* PePena
Expand Down

0 comments on commit 0ced532

Please sign in to comment.