SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
iPhone 3D
                         Programming
                         Chapter 02. Math and Metaphors



                                            2012. 01. 26.
                                            Sanghoon Lee


Sunday, December 9, 12
수학과 비유
                         Graphics Rendering Pipeline & Metaphor

                         Transforms

                         Matrix stack

                         Vector Beautification with C++

                         HelloCone



Sunday, December 9, 12
Sunday, December 9, 12
What we’re going to study!




Sunday, December 9, 12
Different kind of topology




Sunday, December 9, 12
Different kind of topology




                         The first argument specifies the topology




Sunday, December 9, 12
Drawing rectangle




Sunday, December 9, 12
Properties with Vertices




Sunday, December 9, 12
Setting vertex properties examples




Sunday, December 9, 12
Homogeneous coordinates

                    Internally, the OpenGL implementation always converts it
                   into a 4D floating-point number.

                   It’s an artificial construction that allows all transformations to
                   be represented with matrix multiplication.

                    These 4D coordinates are known as homogeneous
                   coordinates.


                   So, shortly after entering the assembly line, all vertex
                   positions become 4D; don’t they need to become 2D at some
                   point? The answer is yes.



Sunday, December 9, 12
The Life of a Vertex

                         Perspective transform   ( removal of w )




Sunday, December 9, 12
Vertex goes from 4D to 2D




                         Early life of a vertex. Top row is conceptual;
                         bottom row is OpenGL’s view

Sunday, December 9, 12
Vertex goes from 4D to 2D




Sunday, December 9, 12
The photography metaphor


                  1. Arrange the various dishes on the table.
                  2. Arrange one or more light sources.
                  3. Position the camera.
                  4. Aim the camera toward the food.
                  5. Adjust the zoom lens.
                  6. Snap the picture.


                                 1. Adjust the camera’s field-of-view angle. (projection matrix)
                                 2. Position the camera and aim it in the appropriate direction.
                                 (view matrix)
                                 3. For each object:
                                    a. Scale, rotate, and translate. (model matrix)
                                    b. Render the object.



Sunday, December 9, 12
ES 1.1




                         ES 2.0




Sunday, December 9, 12
Matrix Multiplication




Sunday, December 9, 12
Model Matrix
                         The three most common operations when
                              positioning an object in a scene

                            Scale

                            Translation

                            Rotation




Sunday, December 9, 12
Setting the Model Matrix (Scale)




Sunday, December 9, 12
Setting the Model Matrix (Scale)




Sunday, December 9, 12
Setting the Model Matrix (Translation)




Sunday, December 9, 12
Setting the Model Matrix (Translation)




Sunday, December 9, 12
Setting the Model Matrix (Rotation ES 1.1)




                            glRotatef(m_currentAngle, 0, 0, 1);


                         counter-clockwise rotation about the Z-axis
                                      angle in degrees
       the latter three arguments define the axis of rotation


Sunday, December 9, 12
Setting the Model Matrix (Rotation ES 2.0)




Sunday, December 9, 12
Setting the Model Matrix (Rotation)

                arbitrary axis rotation
                     * ES 1.1
                       glRotatef generates the matrix for you
                       glRotatef only rotates about the origin




Sunday, December 9, 12
Setting the Model Matrix (Rotation)

                arbitrary axis rotation
                     * ES 2.0




Sunday, December 9, 12
What we have been through




Sunday, December 9, 12
Setting the View Transform




Sunday, December 9, 12
Setting the View Transform

                   The simplest way to create a view matrix




Sunday, December 9, 12
Setting the Projection Transform




                   think of the projection as being the camera's
                                    "zoom lens"




Sunday, December 9, 12
Setting the Projection Transform




                                          ES 1.1

Sunday, December 9, 12
Setting the Projection Transform

            Perspective                                 Orthographic




                                          ES 2.0

Sunday, December 9, 12
Matrix stacks


Sunday, December 9, 12
Matrix stacks




Sunday, December 9, 12
Matrix stacks




                                  Only ES 1.1 supports
                         You need to create by yourself in ES 2.0

Sunday, December 9, 12
Interpolations




Sunday, December 9, 12
Example of
                         easing equations




Sunday, December 9, 12
Quaternions

                         For position keyframes and color keyframes

                                      It's easy

                         What if interpolating between two
                         orientations?



Sunday, December 9, 12
Quaternions

                         Storing an angle for each joint would be
                         insufficient

                         you'd also need the axis of rotation

                         This is known as Axis-Angle notation

                         requires a total of four floating-point values for
                         each joint



Sunday, December 9, 12
Quaternions

                         Storing an angle for each joint would be
                         insufficient

                         you'd also need the axis of rotation
                                Quaternions
                         This is known as Axis-Angle notation

                         requires a total of four floating-point values for
                         each joint



Sunday, December 9, 12
Quaternions

                         Storing an angle for each joint would be
                         insufficient
                                    Study of rotation
                         you'd also need the axis
                                                  and
                         This is understand it!!
                                 known as Axis-Angle notation

                         requires a total of four floating-point values for
                         each joint



Sunday, December 9, 12
Vector Beautification
                   template <typename T>                                             Vector3 Cross(const Vector3& v) const
                   struct Vector3 {                                                  {
                                                                                         return Vector3(y * v.z - z * v.y,
                         Vector3() {}                                                    z * v.x - x * v.z,
                         Vector3(T x, T y, T z) : x(x), y(y), z(z) {}                    x * v.y - y * v.x);
                         void Normalize()                                            }
                         {                                                           T Dot(const Vector3& v) const
                              float length = std::sqrt(x * x + y * y + z * z);        {
                              x /= length;                                               return x * v.x + y * v.y + z * v.z;
                              y /= length;                                           }
                              z /= length;                                           Vector3 operator-() const
                         }                                                           {
                                                                                         return Vector3(-x, -y, -z);
                         Vector3 Normalized() const                                  }
                         {
                             Vector3 v = *this;                                      bool operator==(const Vector3& v) const
                             v.Normalize();                                          {
                             return v;                                                    return x == v.x && y == v.y && z == v.z;
                         }                                                           }

                                                                                     T x;
                                                                                     T y;
                                                                                     T z;
                                                                                };


Sunday, December 9, 12
Vector Beautification
                  vec3 z;
                  normalize(&z, &(eye-target));

                  vec3 cross;
                                                  vec3 z = (eye - target).Normalized();
                  cross(&cross, &up, &z);
                  vec3 x;
                                                  vec3 x = up.Cross(z).Normalized();
                  normalize(&x, &cross);

                                                  vec3 y = z.Cross(x).Normalized();
                  cross(&cross, &up, &z);
                  vec3 y;
                  normalize(&y, &cross);




Sunday, December 9, 12
Hello Cone
                         Fixed Function




Sunday, December 9, 12
Hello Cone
                          Shaders




Sunday, December 9, 12
Further study


                         Graphics Rendering pipeline



                         Quaternion



Sunday, December 9, 12
Q/A




Sunday, December 9, 12

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

iPhone 3D Programming Chapter 02 Math and Metaphors

  • 1. iPhone 3D Programming Chapter 02. Math and Metaphors 2012. 01. 26. Sanghoon Lee Sunday, December 9, 12
  • 2. 수학과 비유 Graphics Rendering Pipeline & Metaphor Transforms Matrix stack Vector Beautification with C++ HelloCone Sunday, December 9, 12
  • 4. What we’re going to study! Sunday, December 9, 12
  • 5. Different kind of topology Sunday, December 9, 12
  • 6. Different kind of topology The first argument specifies the topology Sunday, December 9, 12
  • 9. Setting vertex properties examples Sunday, December 9, 12
  • 10. Homogeneous coordinates Internally, the OpenGL implementation always converts it into a 4D floating-point number. It’s an artificial construction that allows all transformations to be represented with matrix multiplication. These 4D coordinates are known as homogeneous coordinates. So, shortly after entering the assembly line, all vertex positions become 4D; don’t they need to become 2D at some point? The answer is yes. Sunday, December 9, 12
  • 11. The Life of a Vertex Perspective transform ( removal of w ) Sunday, December 9, 12
  • 12. Vertex goes from 4D to 2D Early life of a vertex. Top row is conceptual; bottom row is OpenGL’s view Sunday, December 9, 12
  • 13. Vertex goes from 4D to 2D Sunday, December 9, 12
  • 14. The photography metaphor 1. Arrange the various dishes on the table. 2. Arrange one or more light sources. 3. Position the camera. 4. Aim the camera toward the food. 5. Adjust the zoom lens. 6. Snap the picture. 1. Adjust the camera’s field-of-view angle. (projection matrix) 2. Position the camera and aim it in the appropriate direction. (view matrix) 3. For each object: a. Scale, rotate, and translate. (model matrix) b. Render the object. Sunday, December 9, 12
  • 15. ES 1.1 ES 2.0 Sunday, December 9, 12
  • 17. Model Matrix The three most common operations when positioning an object in a scene Scale Translation Rotation Sunday, December 9, 12
  • 18. Setting the Model Matrix (Scale) Sunday, December 9, 12
  • 19. Setting the Model Matrix (Scale) Sunday, December 9, 12
  • 20. Setting the Model Matrix (Translation) Sunday, December 9, 12
  • 21. Setting the Model Matrix (Translation) Sunday, December 9, 12
  • 22. Setting the Model Matrix (Rotation ES 1.1) glRotatef(m_currentAngle, 0, 0, 1); counter-clockwise rotation about the Z-axis angle in degrees the latter three arguments define the axis of rotation Sunday, December 9, 12
  • 23. Setting the Model Matrix (Rotation ES 2.0) Sunday, December 9, 12
  • 24. Setting the Model Matrix (Rotation) arbitrary axis rotation * ES 1.1 glRotatef generates the matrix for you glRotatef only rotates about the origin Sunday, December 9, 12
  • 25. Setting the Model Matrix (Rotation) arbitrary axis rotation * ES 2.0 Sunday, December 9, 12
  • 26. What we have been through Sunday, December 9, 12
  • 27. Setting the View Transform Sunday, December 9, 12
  • 28. Setting the View Transform The simplest way to create a view matrix Sunday, December 9, 12
  • 29. Setting the Projection Transform think of the projection as being the camera's "zoom lens" Sunday, December 9, 12
  • 30. Setting the Projection Transform ES 1.1 Sunday, December 9, 12
  • 31. Setting the Projection Transform Perspective Orthographic ES 2.0 Sunday, December 9, 12
  • 34. Matrix stacks Only ES 1.1 supports You need to create by yourself in ES 2.0 Sunday, December 9, 12
  • 36. Example of easing equations Sunday, December 9, 12
  • 37. Quaternions For position keyframes and color keyframes It's easy What if interpolating between two orientations? Sunday, December 9, 12
  • 38. Quaternions Storing an angle for each joint would be insufficient you'd also need the axis of rotation This is known as Axis-Angle notation requires a total of four floating-point values for each joint Sunday, December 9, 12
  • 39. Quaternions Storing an angle for each joint would be insufficient you'd also need the axis of rotation Quaternions This is known as Axis-Angle notation requires a total of four floating-point values for each joint Sunday, December 9, 12
  • 40. Quaternions Storing an angle for each joint would be insufficient Study of rotation you'd also need the axis and This is understand it!! known as Axis-Angle notation requires a total of four floating-point values for each joint Sunday, December 9, 12
  • 41. Vector Beautification template <typename T> Vector3 Cross(const Vector3& v) const struct Vector3 { { return Vector3(y * v.z - z * v.y, Vector3() {} z * v.x - x * v.z, Vector3(T x, T y, T z) : x(x), y(y), z(z) {} x * v.y - y * v.x); void Normalize() } { T Dot(const Vector3& v) const float length = std::sqrt(x * x + y * y + z * z); { x /= length; return x * v.x + y * v.y + z * v.z; y /= length; } z /= length; Vector3 operator-() const } { return Vector3(-x, -y, -z); Vector3 Normalized() const } { Vector3 v = *this; bool operator==(const Vector3& v) const v.Normalize(); { return v; return x == v.x && y == v.y && z == v.z; } } T x; T y; T z; }; Sunday, December 9, 12
  • 42. Vector Beautification vec3 z; normalize(&z, &(eye-target)); vec3 cross; vec3 z = (eye - target).Normalized(); cross(&cross, &up, &z); vec3 x; vec3 x = up.Cross(z).Normalized(); normalize(&x, &cross); vec3 y = z.Cross(x).Normalized(); cross(&cross, &up, &z); vec3 y; normalize(&y, &cross); Sunday, December 9, 12
  • 43. Hello Cone Fixed Function Sunday, December 9, 12
  • 44. Hello Cone Shaders Sunday, December 9, 12
  • 45. Further study Graphics Rendering pipeline Quaternion Sunday, December 9, 12