Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3675904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:02:06+00:00 2026-05-19T03:02:06+00:00

I was studying Ray Tracing on http://www.devmaster.net/articles/raytracing_series/part1.php when I came across this piece of

  • 0

I was studying Ray Tracing on http://www.devmaster.net/articles/raytracing_series/part1.php when I came across this piece of code:

void Engine::InitRender()
{
// set first line to draw to
m_CurrLine = 20;
// set pixel buffer address of first pixel
m_PPos = 20 * m_Width;
// screen plane in world space coordinates
m_WX1 = -4, m_WX2 = 4, m_WY1 = m_SY = 3, m_WY2 = -3;
// calculate deltas for interpolation
m_DX = (m_WX2 - m_WX1) / m_Width;
m_DY = (m_WY2 - m_WY1) / m_Height;
m_SY += 20 * m_DY;
// allocate space to store pointers to primitives for previous line
m_LastRow = new Primitive*[m_Width];
memset( m_LastRow, 0, m_Width * 4 );
}

I’m quite confused on how the author map screen coordinates to world coordinates…
Can anyone please tell me how the author derived these lines?
Or tell me how one would map screen coordinates to world coordinates?

// screen plane in world space coordinates
m_WX1 = -4, m_WX2 = 4, m_WY1 = m_SY = 3, m_WY2 = -3;

Thank you in advance!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:02:06+00:00Added an answer on May 19, 2026 at 3:02 am

    EDIT: Here is relevant code from raytracer.cpp:

    // render scene
    vector3 o( 0, 0, -5 );
    
    // initialize timer
    int msecs = GetTickCount();
    
    // reset last found primitive pointer
    Primitive* lastprim = 0;
    
    // render remaining lines
    for(int y = m_CurrLine; y < (m_Height - 20); y++)
    {
        m_SX = m_WX1;
    
        // render pixels for current line
        for ( int x = 0; x < m_Width; x++ )
        {
            // fire primary ray
            Color acc( 0, 0, 0 );
            vector3 dir = vector3( m_SX, m_SY, 0 ) - o;
            NORMALIZE( dir );
            Ray r( o, dir );
            float dist;
            Primitive* prim = Raytrace( r, acc, 1, 1.0f, dist );
            int red = (int)(acc.r * 256);
            int green = (int)(acc.g * 256);
            int blue = (int)(acc.b * 256);
            if (red > 255) red = 255;
            if (green > 255) green = 255;
            if (blue > 255) blue = 255;
            m_Dest[m_PPos++] = (red << 16) + (green << 8) + blue;
            m_SX += m_DX;
        }
    
        m_SY += m_DY;
    
        // see if we've been working to long already
        if ((GetTickCount() - msecs) > 100) 
        {
            // return control to windows so the screen gets updated
            m_CurrLine = y + 1;
            return false;
        }
    }
    
    return true;
    

    Therefore the camera is at (0,0,-5) and the screen onto which the world is being projected has top-left corner (-4,3,0) and bottom-right corner (4,-3,0).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im studying for finals and i came across this question: write a PHP script
While studying for the Zend PHP Exam I came across the following contradicting information:
While studying for a Functional Programming exam, I came across the following questions from
While studying for a Functional Programming exam, I came across the following question from
I was studying an open source code where I came across the following line
I am studying about various trees, and came across AVL trees and splay trees.
studying some sample code from an iOS programming course (cs193p fall2010) i came across
While studying an implementation of Group signature I came across code where Group certificate
Studying MS Exam 70-536 .Net Foundation I've got to Chapter 11 Application Security and
In studying actionscript 3's graphics class, I've come across the undocumented drawRoundRectComplex() method. It's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.