Ray mrMul(const Matrix matrix, const Ray ray) { return makeRay(mvMul(matrix, ray.origin), vNormalized(mvMulDir(matrix, ray.direction))); }
tVector2D Lapidem_Math::Vector2DNormalize( tVector2D _v ) { float fLength( Vector2DLength( _v ) ); tVector2D vNormalized( _v / fLength ); return vNormalized; }
Color sceneTraceRayAtPixel(const Scene *scene, const int currentPixel, const int width, const int height, const int numCameraRayBounces) { const float cameraFov = 40; const float cameraAspectRatio = 1; float maxX = tanf(cameraFov/360.0*PI); float x = ((((currentPixel % width) + randf()) / width ) * 2 - 1) * maxX; float y = -((((currentPixel / width) + randf()) / height) * 2 - 1) * maxX / cameraAspectRatio; return sceneTraceRay(scene, mrMul(mInversed(scene->cameraOrientation), makeRay(makeVectorOrigo(), vNormalized(makeVector(x, y, 1)))), numCameraRayBounces); }