New Paste :: Recent Pastes:: Add Line Numbers
ray plane intersection by SUNSTAR
bool distRayPlane(vec3 vRayOrigin, vec3 vRayVector, vec3 vPlaneNormal, float fPlaneDist, vec3 vIntersection) { float fCosAlpha; float fDeltaDist; float fRayDist; fCosAlpha = DotProduct(vRayVector , vPlaneNormal); if (fCosAlpha==0) return false; //ray is parallel to the plane fDeltaDist = fPlaneDist - DotProduct(vRayOrigin,vPlaneNormal); fRayDist = fDeltaDist/fCosAlpha; vIntersection = vRayOrigin + ScalarProduct(vRayVector, fRayDist); return true; }