{"id":20500,"date":"2023-02-01T09:12:20","date_gmt":"2023-02-01T09:12:20","guid":{"rendered":"https:\/\/www.booksofall.com\/es\/?post_type=product&#038;p=20500"},"modified":"2023-02-01T09:12:20","modified_gmt":"2023-02-01T09:12:20","slug":"ray-tracing-the-rest-of-your-life","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/","title":{"rendered":"Ray Tracing: The Rest of Your Life"},"content":{"rendered":"<h2><b>A Simple Monte Carlo Program\u00a0<\/b><\/h2>\n<p>Let\u2019s start with one of the simplest <a href=\"https:\/\/www.investopedia.com\/terms\/m\/montecarlosimulation.asp\">Monte Carlo (MC)<\/a> programs. MC programs give a statistical estimate of an answer, and this estimate gets more and more accurate the longer you run it. This basic characteristic of simple programs producing noisy but ever- better answers is what MC is all about, and it is especially good for applications like graphics where great accuracy is not needed.<\/p>\n<h2><b>Estimating Pi\u00a0<\/b><\/h2>\n<p>As an example, let\u2019s <a href=\"https:\/\/www.wikihow.com\/Calculate-Pi\">estimate<\/a> <a href=\"https:\/\/www.wikihow.com\/Calculate-Pi\">\u03c0<\/a>. There are many ways to do this, with the <a href=\"https:\/\/mste.illinois.edu\/activity\/buffon\/\">Buffon Needle<\/a> problem being a classic case study. We\u2019ll do a variation inspired by that. Suppose you have a circle inscribed inside a square:<\/p>\n<p><b>Figure 1:<\/b>\u00a0Estimating \u03c0 with a circle inside a square<\/p>\n<p>Now, suppose you pick random points inside the square. The fraction of those random points that end up inside the circle should be proportional to the area of the circle. The exact fraction should in fact be the ratio of the circle area to the square area. Fraction:<\/p>\n<p>\u03c0r2(2r)2=\u03c04<\/p>\n<p>Since the rr cancels out, we can pick whatever is computationally convenient. Let\u2019s go with r=1r=1, centered at the origin:<\/p>\n<p>#include &#8220;rtweekend.h&#8221;<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;iomanip&gt;<br \/>\n#include &lt;math.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<\/p>\n<p>int main() {<br \/>\nint N = 1000;<br \/>\nint inside_circle = 0;<br \/>\nfor (int i = 0; i &lt; N; i++) {<br \/>\nauto x = random_double(-1,1);<br \/>\nauto y = random_double(-1,1);<br \/>\nif (x*x + y*y &lt; 1)<br \/>\ninside_circle++;<br \/>\n}<br \/>\nstd::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision(12);<br \/>\nstd::cout &lt;&lt; &#8220;Estimate of Pi = &#8221; &lt;&lt; 4*double(inside_circle) \/ N &lt;&lt; &#8216;\\n&#8217;;<br \/>\n}<\/p>\n<p><b>Listing 1:<\/b>\u00a0[pi.cc] Estimating \u03c0<\/p>\n<p>The answer of \u03c0\u03c0 found will vary from computer to computer based on the initial random seed. On my computer, this gives me the answer Estimate of Pi = 3.0880000000<\/p>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/creative-commons-license-cc-ray-tracing-the-next-week-18r3a67me4?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":20504,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"After learning the basic knowledge of ray tracing, we can then start learn more deeper about how to use them in our work with this book!"},"product_brand":[],"product_cat":[297],"product_tag":[],"class_list":{"0":"post-20500","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-graphics-programming","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Ray Tracing: The Rest of Your Life - BooksOfAll Spanish<\/title>\n<meta name=\"description\" content=\"After learning the basic knowledge of ray tracing, we can then start learn more deeper about how to use them in our work with this book!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ray Tracing: The Rest of Your Life - BooksOfAll Spanish\" \/>\n<meta property=\"og:description\" content=\"After learning the basic knowledge of ray tracing, we can then start learn more deeper about how to use them in our work with this book!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll Spanish\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/\",\"url\":\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/\",\"name\":\"Ray Tracing: The Rest of Your Life - BooksOfAll Spanish\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/es\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg\",\"datePublished\":\"2023-02-01T09:12:20+00:00\",\"description\":\"After learning the basic knowledge of ray tracing, we can then start learn more deeper about how to use them in our work with this book!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg\",\"width\":\"827\",\"height\":\"1169\",\"caption\":\"Ray Tracing: The Rest of Your Life\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/es\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/es\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ray Tracing: The Rest of Your Life\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/es\/#website\",\"url\":\"https:\/\/www.booksofall.com\/es\/\",\"name\":\"BooksOfAll Spanish\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/es\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/es\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/es\/#organization\",\"name\":\"BooksOfAll Spanish\",\"url\":\"https:\/\/www.booksofall.com\/es\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/www.booksofall.com\/es\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll Spanish\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/es\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ray Tracing: The Rest of Your Life - BooksOfAll Spanish","description":"After learning the basic knowledge of ray tracing, we can then start learn more deeper about how to use them in our work with this book!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/","og_locale":"es_ES","og_type":"article","og_title":"Ray Tracing: The Rest of Your Life - BooksOfAll Spanish","og_description":"After learning the basic knowledge of ray tracing, we can then start learn more deeper about how to use them in our work with this book!","og_url":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/","og_site_name":"BooksOfAll Spanish","og_image":[{"url":"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg","twitter_misc":{"Tiempo de lectura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/","url":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/","name":"Ray Tracing: The Rest of Your Life - BooksOfAll Spanish","isPartOf":{"@id":"https:\/\/www.booksofall.com\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg","datePublished":"2023-02-01T09:12:20+00:00","description":"After learning the basic knowledge of ray tracing, we can then start learn more deeper about how to use them in our work with this book!","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#primaryimage","url":"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg","contentUrl":"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2023\/02\/Ray-Tracing-The-Rest-of-Your-Life.jpg","width":"827","height":"1169","caption":"Ray Tracing: The Rest of Your Life"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/es\/ray-tracing-the-rest-of-your-life\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/es\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/es\/categories\/"},{"@type":"ListItem","position":3,"name":"Ray Tracing: The Rest of Your Life"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/es\/#website","url":"https:\/\/www.booksofall.com\/es\/","name":"BooksOfAll Spanish","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/es\/#organization","name":"BooksOfAll Spanish","url":"https:\/\/www.booksofall.com\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.booksofall.com\/es\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/es\/wp-content\/uploads\/sites\/5\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll Spanish"},"image":{"@id":"https:\/\/www.booksofall.com\/es\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/product\/20500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/media\/20504"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/media?parent=20500"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/product_brand?post=20500"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/product_cat?post=20500"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/es\/wp-json\/wp\/v2\/product_tag?post=20500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}