Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- --*--*--*--*--*--*--*--*--*--*--*--*--*--*--
- --* MonitorLink with OpenCCSensors *--
- --* https://pastebin.com/qaYR1mMu *--
- --* by: GravityCube and Archmaestro *--
- --*--*--*--*--*--*--*--*--*--*--*--*--*--*--
- Changelog:
- 1.0.0 First Release
- --]]
- --------------------------------------------------------
- --> Variables <--
- --------------------------------------------------------
- x0 = 6.19744
- y0 = 5.1204934
- x00 = -0.8715613
- y00 = 1.1154351
- proX = 142/math.abs(x0-x00)
- proY = 51/math.abs(y0-y00)
- --------------------------------------------------------
- --> Main Program <--
- --------------------------------------------------------
- function make(xval, yval, zval)
- return {x=xval, y=yval, z=zval}
- end
- function plus(lhs, rhs)
- return make(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z)
- end
- function minus(lhs, rhs)
- return make(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z)
- end
- function times(lhs, scale)
- return make(scale * lhs.x, scale * lhs.y, scale * lhs.z)
- end
- function dot(lhs, rhs)
- return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z
- end
- function tostr(val)
- return "(" .. val.x .. ", " .. val.y .. ", " .. val.z .. ")"
- end
- function intersectPoint(rayVector, rayPoint, planeNormal, planePoint)
- diff = minus(rayPoint, planePoint)
- prod1 = dot(diff, planeNormal)
- prod2 = dot(rayVector, planeNormal)
- prod3 = prod1 / prod2
- return minus(rayPoint, times(rayVector, prod3))
- end
- function getLookVector(yaw,pitch)
- local yaw = (yaw+360+90)*2*math.pi/360
- local pitch = pitch*2*math.pi/360
- local xzLen = math.cos(pitch)
- local x = -xzLen * math.cos(yaw)
- local y = -math.sin(pitch)
- local z = -xzLen * math.sin(-yaw)
- return make(x,y,z)
- end
- function getCursorPos(x1, y1, z1, yaw, pitch)
- v1 = getLookVector(yaw,pitch)
- p1 = make(x1,y1+1.62,z1)
- vn = make(0,0,1)
- vp = make(0,0,0.5)
- --NEED TO ADD DIRECTION CALC
- int = intersectPoint(v1, p1, vn, vp)
- local x = math.floor((x0-int.x)*proX)+1
- local y = math.floor((y0-int.y)*proY)+1
- return x, y
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement