- Joined
- Dec 12, 2008
- Messages
- 7,385
I can't seem to think of any more functions I can include in this library:
Any ideas?
I'm currently just fixing it so that it can't divide by 0.
JASS:
//****************************************************
//
// Linear Functions
// -Magtheridon96
//
//****************************************************
library LinearFunctions
struct Linear
real slope
real yIntercept
method parallel takes thistype d returns boolean
return this.slope == d.slope
endmethod
method intersects takes thistype d returns boolean
return not this.parallel(d)
endmethod
method perpendicular takes thistype d returns boolean
return this.slope * d.slope == -1
endmethod
static method create takes real x, real y, real x2, real y2 returns thistype
local thistype this = thistype.allocate()
set .slope = (y2-y)/(x2-x)
set .yIntercept = y - .slope * x
return this
endmethod
method getY takes real x returns real
return .slope * x + .yIntercept
endmethod
method getX takes real y returns real
return (y - .yIntercept) / .slope
endmethod
method getSlope takes nothing returns real
return .slope
endmethod
method getYintercept takes nothing returns real
return .yIntercept
endmethod
method getBaseAngle takes nothing returns real
return Atan2(getY(2)-getY(1),1)
endmethod
endstruct
endlibrary
Any ideas?
I'm currently just fixing it so that it can't divide by 0.