1 Ring, Circle, Cone Chapter 4. 2 Triangle rotating We have a triangle in the following position We want to rotate it around line y =  2. For this purpose,

Slides:



Advertisements
Similar presentations
RenderMan - Writing RenderMan Shaders (2)-. Transforming Tiles Transforming texture coordinates has an "inverse" effect on the appearance of the pattern.
Advertisements

Algebra II Chapter 10 Section 3.
Computer Graphics 2D & 3D Transformation.
1 2D Graphics CIS 487/587 Bruce R. Maxim UM-Dearborn.
1 3D Vector & Matrix Chapter 2. 2 Vector Definition: Vector is a line segment that has the direction. The length of the line segment is called the magnitude.
Honors Geometry Section 10.3 Trigonometry on the Unit Circle
Goal: to rotate a figure around a central point
TRANSFORMATIONS.
Section 7.2 Solids of Revolution. 1 st Day Solids with Known Cross Sections.
Rotation of Two-Dimensional Solids
Unit 8: Applying Formulas Sections: 10-3, 10-5, 10-6, , 11-4, 11-5, and 11-6.
1 Cube & Sphere Chapter 5. 2 Draw Cube Cube has 8 vertices as the picture shows. Each vertex has color of Red, Blue, Green or Yellow. We need to draw.
1 Texture Chapter 6. 2 What is Texture? Texture is a D3D interface that can map a partial of a picture to a 3D space by using Texture coordinates. The.
1 X file & Mesh Chapter 8. 2 What is X file? 1.X file is a file that is used to store D3D program's data. 2.Any X file has extension *.x. 3.X file could.
2.4: Rotations.
1 Viewing & Projective Window Chapter 3. 2 D3D virtual viewpoint Definition: virtual viewpoint is like a camera that was positioned in some where and.
Algebraic Representations of Transformations Day 2
Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,
1 Manage Mesh Data Chapter 8. 2 How to manage Mesh data The most important two objects of mesh are VertexBuffer and IndexBuffer, which can obtained by.
TRIGONOMETRY - Angles Trigonometry began as a study of the right triangle. It was discovered that certain relationships between the sides of the right.
Transformations on the Coordinate Plane. Example 2-2a A trapezoid has vertices W(–1, 4), X(4, 4), Y(4, 1) and Z(–3, 1). Trapezoid WXYZ is reflected.
In the diagram above, corresponding points on the two figures are related. Suppose P is any point on the original figure and P’ is the corresponding point.
Chapter Surface Area of Pyramids and Cones.
Angles and the Unit Circle. An angle is in standard position when: 1) The vertex is at the origin. 2) One leg is on the positive x – axis. (This is the.
Triangles 1st year P26 Chapter 4.
FORM:  Uses a shape and adds “substance”-All forms are made up of one or more of the basic shapes in various combinations. (Three-Dimensional) A. Pyramid-
Section 11.1 Section 11.2 Conic Sections The Parabola.
Conics Conics Review. Graph It! Write the Equation?
The Circle. Examples (1) – (5) Determine the center and radius of the circle having the given equation. Identify four points of the circle.
Chapter 4-1: Measures of Angles as Rotations. Review… Angle: The union of two rays which are its sides with the same vertex or endpoint. Angle: The rotation.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
Warm-up . What do we need to keep the same? What do we need to change?
Equations of Circles. You can write an equation of a circle in a coordinate plane, if you know: Its radius The coordinates of its center.
Coordinates and Design. What You Will Learn: To use ordered pairs to plot points on a Cartesian plane To draw designs on a Cartesian plane To identify.
In the last several lessons, you have described translations using coordinates. You have also developed strategies for determining where an object started.
Surface Area of a Cylinder Geometry. Overview Find the area of a circle Find the circumference of a circle Find the area of rectangle Find the surface.
13-2 ANGLES AND THE UNIT CIRCLE FIND ANGLES IN STANDARD POSITION BY USING COORDINATES OF POINTS ON THE UNIT CIRCLE.
8-7 Transformation Objective: Students recognize, describe, and show transformation.
Chapter 3 Lesson 2 The Graph Translation Theorem.
Surface Area and Volume of Cylinders Mr. Bench PVMS.
ROTATIONS LESSON 30.
Coordinate Algebra Practice EOCT Answers Unit 5.
Graphics CSCI 343, Fall 2017 Lecture 13 More on WebGL
Transformations.
11.4 Rotations 1/12/17.
Cross sections of 3-D solids
Unit 3 – Lesson 6 Solids.
How to transform a shape with a rotation
Three-Dimensional Graphics
Unit 1 Transformations in the Coordinate Plane
Transformations Example Draw the line Draw 1 at , ,
Angles and Angle Measure
FP1 Matrices Transformations
A movement of a figure in a plane.
A movement of a figure in a plane.
Perform the following transformations on the point (4,−8):
4-4 Geometric Transformations with Matrices
Algebraic Representations of Transformations
1. Turn to a piece of graph paper in your module packet. 2. Make three graphs for number one. 3. In each graph draw the triangle.
When you are on an amusement park ride,
Warm Up 1. A point P has coordinates (1, 4). What are its new coordinates after reflecting point P across the x-axis? [A] (-1, 4) [B] (1, 4) [C] (1, -4)
Rotation.
Transformations with Matrices
Geometric Transformations
Transformations Review
Unit 37 Further Transformations
Class 18 front and back lighting convex sets, convex hull
Coordinate Algebra Practice EOCT Answers Unit 5.
Presentation transcript:

1 Ring, Circle, Cone Chapter 4

2 Triangle rotating We have a triangle in the following position We want to rotate it around line y =  2. For this purpose, we have make a translation T (2,0,0), following a rotation about Y axis, then make the reverse translation T (  2,0,0). (  3,0) (  1,0) (  2,1.73) Y X

3 Set vertex private void SetVertex() { verts = new CustomVertex.PositionColored[3]; verts[0].X=-3.0f;verts[0].Y=0.0f;verts[0].Z=0.0f; verts[0].Color = Color.Yellow.ToArgb(); verts[1].X=-1.0f;verts[1].Y=0.0f;verts[1].Z=0.0f; verts[1].Color = Color.FromArgb(0,0,255).ToArgb() ; verts[2].X=-2.0f; verts[2].Y=1.73f;verts[2].Z=0.0f; verts[2].Color = Color.Red.ToArgb(); }

4 Set Rotation private void SetRotation() { float a = (float)Environment.TickCount /1000.0f; float theta = a*2.0f*(float)Math.PI; Matrix mR = Matrix.RotationY(theta) ; Matrix T1 = Matrix.Translation(2.0f, 0.0f, 0.0f); Matrix T2 = Matrix.Translation(-2.0f, 0.0f, 0.0f); Matrix Mat = T1*mR*T2; m_device.Transform.World=Mat; } Note: In the combination of matrix, the left matrix takes the Transformation action first. So in the above, T1 first, mR second, T2 last

5 Make a Ring We have a ring in the following position with inner radius 0.5 and the outer radius 1. Both circles has equation (3,0) Y X (2,0) (1,0)

6 Set Ring vertex private void SetRingVertex() { v_ring = new CustomVertex.PositionColored[122]; float theta = 2.0f*(float)Math.PI/60.0f; // 6º for(int k=0; k<61; k++) { v_ring[2*k].X=2+0.5f*(float)Math.Cos(theta*k); v_ring[2*k].Y=0.5f*(float)Math.Sin(theta*k); v_ring[2*k].Z=0.0f; // inner circle v_ring[2*k].Color=Color.Red.ToArgb(); // red v_ring[2*k+1].X=2+(float)Math.Cos(theta*k); v_ring[2*k+1].Y=(float)Math.Sin(theta*k); v_ring[2*k+1].Z=0.0f;// outer circle v_ring[2*k+1].Color=Color.White.ToArgb(); //white }

7 Multiple Rotations private void SetRotation() { float a1 = (float)Environment.TickCount /1000.0f; float theta1 = a1*2.0f*(float)Math.PI; float a2 = (float)Environment.TickCount /1300.0f; float theta2 = a2*2.0f*(float)Math.PI; float a3 = (float)Environment.TickCount /1700.0f; float theta3 = a2*2.0f*(float)Math.PI; Matrix RX = Matrix.RotationY(theta1) ; Matrix RY = Matrix.RotationX(theta2) ; Matrix RZ = Matrix.RotationZ(theta3) ; Matrix T1 = Matrix.Translation(2.0f, 0.0f, 0.0f); Matrix T2 = Matrix.Translation(-2.0f, 0.0f, 0.0f); m_device.Transform.World=T2*RX*RY*RZ*T1; }

8 Draw Ring VBR = new VertexBuffer ( typeof(CustomVertex.PositionColored), 122, m_device, 0, CustomVertex.PositionColored.Format, Pool.Default); GraphicsStream stream = VBR.Lock(0, 0, 0); stream.Write(this.v_ring); VBR.Unlock(); m_device.SetStreamSource( 0, VBR, 0); SetRotationR(); m_device.DrawPrimitives( PrimitiveType.TriangleStrip, 0, 120); // omit adding event handling code

9 Output

10 Make a Circle If we have a circle center at (2,0) with radius 1. The circles has equation (3,0) Y X (2,0) (1,0)

11 Set Circle vertex private void SetCircleVertex() { v_circle[]= new CustomVertex.PositionColored[62]; v_circle[0].X=2.0f; v_ circle[0].Y=0.0f; v_ circle[0].Z=0.0f; // circle center v_ circle[0].Color=Color.Red.ToArgb(); // red float theta = 2.0f*(float)Math.PI/60.0f; // 6º for(int k=1; k<62; k++) { v_circle[k].X=2+(float)Math.Cos(theta*k); v_ circle[k].Y=(float)Math.Sin(theta*k); v_ circle[k].Z=0.0f;// circle v_ circle[k].Color=Color.White.ToArgb(); //white }

12 Draw Circle code m_device.SetStreamSource( 0, VBCircle, 0); SetRotationR(); m_device.DrawPrimitives( PrimitiveType.TriangleFan, 0, 60);

13 Direction of a triangle Any triangle has 3 vertices v1, v2, v2. Suppose we draw this triangle with order v1  v2  v2. v1 v2 v3 v1 v2 v3 Then this direction could be either clockwise or anti-clockwise ( counter-clockwise) clockwisecounter-clockwise

14 Set CULLMODE If we do not want to draw anti-clockwise triangle only then set m_device.RenderState.CullMode = Cull.Clockwise; If we do not want to draw clockwise triangle only then set m_device.RenderState.CullMode = Cull.CounterClockwise; If we want to draw all direction triangle then set m_device.RenderState.CullMode = Cull.None; Note: When drawing Triangle Strip, the first one must be clockwise, the followings could be any directions.

15 Draw Cone Cube has one lateral surface and one base circle. So we will pick 62 points: one at (0, 2, 0), one is the base circle center (0, 0, 0). Also 61 points at the circle. Radius=1.2 The lateral surface will be draw from method: PrimitiveType.TriangleFan the direction is counter-clockwise. The base circle is also use PrimitiveType.TriangleFan, but the direction is clockwise. Also we need to change the vertex buffer value, during the drawing.

16 Set Cone Vertex void SetVertex() { v_cone = new CustomVertex.PositionColored[62]; v_cone[0].X = 0.0f; v_cone[0].Y = 2.0f; v_cone[0].Z = 0.0f; v_cone[0].Color =Color.Yellow.ToArgb(); float theta = 2.0f*(float)Math.PI/60.0f; for(int k=1; k<62; k++) { v_cone[k].X = 1.2f*(float)Math.Cos(k*theta); v_cone[k].Y = 0.0f; v_cone[k].Z = 1.2f*(float)Math.Sin(k*theta); v_cone[k].Color =Color.Blue.ToArgb(); }

17 void Render() { m_device.Clear(ClearFlags.Target, Color.Black.ToArgb(),1.0f,0); m_device.BeginScene(); m_device.SetStreamSource( 0, VB, 0); SetRotation(); m_device.RenderState.CullMode = Cull.Clockwise; m_device.DrawPrimitives(PrimitiveType.TriangleFan, 0,60); m_device.RenderState.CullMode = Cull.CounterClockwise; m_device.DrawPrimitives(PrimitiveType.TriangleFan, 1,59); m_device.EndScene(); m_device.Present(); }

18 Output

19 Need to add Cylinder two colors