Hi guys I'm doing a Ray cast function and have been given 5 steps on how to do it this is step 1-:
for (int nColumn = 0; nColumn < m_nViewWidth; nColumn++)
{
// ***************************************************************************************
// STEP 1: Use the starting position of the ray (fRayStartX, fRayStartY), the viewing
// angle (uViewingAngle) and the column angle for this pixel column (nColumnAngle) to
// calculate the end position (fRayEndX, fRayEndY) of a ray 1024 units long.
// ***************************************************************************************
float fRayEndX;
float fRayEndY;
int RayLength = 1024;
// Avoid the situation where the column angle is 0
if (nColumnAngle == 0) { nColumnAngle++; }
grid ;
// Calculate the angle of ray in with respect to the world
// Ensure the angle is in the range of 0-4096
int rayAngle = nColumnAngle + uViewingAngle;
if(rayAngle < 0)
{
rayAngle = 0;
}
else
if (rayAngle > 4096)
{
rayAngle = 4096;
}
// Look up the sin and cos of the ray angle in the relevant arrays
// Rotate endpoint of a ray 1024 units long by the viewing angle:
fRayEndX = (RayAngleSin * RayLength) /** fSinArray[uViewingAngle] )*/ + fRayStartX;
fRayEndY = (RayAngleCos * RayLength) /** fCosArray[uViewingAngle] )*/ + fRayStartY;
// Create variables to hold the ray's current position (fRayX, fRayY) and initialise them
// to the start position.
float fRayX = fRayStartX;
float fRayY = fRayStartY;
Can someone please tell me how i go about rotating the endpoint of the ray you can see i've had a go but i don't know if it is correct or not.