How To Draw A Circle Of Radius 1 On A Computer (For A Computer)

Similar documents
Biggar High School Mathematics Department. National 5 Learning Intentions & Success Criteria: Assessing My Progress

Trigonometric Functions: The Unit Circle

Dear Accelerated Pre-Calculus Student:

Figure 1.1 Vector A and Vector F

Angles and Quadrants. Angle Relationships and Degree Measurement. Chapter 7: Trigonometry

ANALYTICAL METHODS FOR ENGINEERS

Trigonometric Functions and Triangles

Additional Topics in Math

1. A student followed the given steps below to complete a construction. Which type of construction is best represented by the steps given above?

Warm-up Theorems about triangles. Geometry. Theorems about triangles. Misha Lavrov. ARML Practice 12/15/2013

Week 13 Trigonometric Form of Complex Numbers

Triangle Trigonometry and Circles

Lecture 8 : Coordinate Geometry. The coordinate plane The points on a line can be referenced if we choose an origin and a unit of 20

CIRCLE COORDINATE GEOMETRY

Trigonometry Hard Problems

New York State Student Learning Objective: Regents Geometry

Review of Fundamental Mathematics

Trigonometric Functions and Equations

National 5 Mathematics Course Assessment Specification (C747 75)

Solving Simultaneous Equations and Matrices

Displacement (x) Velocity (v) Acceleration (a) x = f(t) differentiate v = dx Acceleration Velocity (v) Displacement x

Contents. 2 Lines and Circles Cartesian Coordinates Distance and Midpoint Formulas Lines Circles...

Solutions to Exercises, Section 5.1

High School Geometry Test Sampler Math Common Core Sampler Test

Solutions to Practice Problems

SECTION 2.2. Distance and Midpoint Formulas; Circles

Section 6-3 Double-Angle and Half-Angle Identities

Geometry Notes PERIMETER AND AREA

In order to describe motion you need to describe the following properties.

One advantage of this algebraic approach is that we can write down

13.4 THE CROSS PRODUCT

6.1 Basic Right Triangle Trigonometry

Designing and Drawing a Sprocket Visualizing ideas through the creation of CAD solid models is a key engineering skill.

Section 11.4: Equations of Lines and Planes

5.3 The Cross Product in R 3

Geometry Notes RIGHT TRIANGLE TRIGONOMETRY

Parallel and Perpendicular. We show a small box in one of the angles to show that the lines are perpendicular.

Trigonometry Review with the Unit Circle: All the trig. you ll ever need to know in Calculus

PHYSICS 151 Notes for Online Lecture #6

Understanding Poles and Zeros

Geometry of Vectors. 1 Cartesian Coordinates. Carlo Tomasi

Sample Test Questions

3. KINEMATICS IN TWO DIMENSIONS; VECTORS.

MAC Learning Objectives. Module 10. Polar Form of Complex Numbers. There are two major topics in this module:

How To Solve The Pythagorean Triangle

Higher Education Math Placement

with functions, expressions and equations which follow in units 3 and 4.

Lesson 19: Equations for Tangent Lines to Circles

Geometry Enduring Understandings Students will understand 1. that all circles are similar.

Trigonometry. An easy way to remember trigonometric properties is:

Section 1.1. Introduction to R n

Unit 3: Circles and Volume

Rotated Ellipses. And Their Intersections With Lines. Mark C. Hendricks, Ph.D. Copyright March 8, 2012

Curve Fitting, Loglog Plots, and Semilog Plots 1

Thnkwell s Homeschool Precalculus Course Lesson Plan: 36 weeks

2 Session Two - Complex Numbers and Vectors

ab = c a If the coefficients a,b and c are real then either α and β are real or α and β are complex conjugates

The Vector or Cross Product

CAMI Education linked to CAPS: Mathematics

Geometry and Measurement

Unit 6 Trigonometric Identities, Equations, and Applications

South Carolina College- and Career-Ready (SCCCR) Pre-Calculus

Introduction and Mathematical Concepts

Geometry. Higher Mathematics Courses 69. Geometry

6. Vectors Scott Surgent (surgent@asu.edu)

x 2 + y 2 = 1 y 1 = x 2 + 2x y = x 2 + 2x + 1

v v ax v a x a v a v = = = Since F = ma, it follows that a = F/m. The mass of the arrow is unchanged, and ( )

2014 Chapter Competition Solutions

CCGPS UNIT 3 Semester 1 ANALYTIC GEOMETRY Page 1 of 32. Circles and Volumes Name:

Solutions to old Exam 1 problems

EDEXCEL NATIONAL CERTIFICATE/DIPLOMA MECHANICAL PRINCIPLES AND APPLICATIONS NQF LEVEL 3 OUTCOME 1 - LOADING SYSTEMS

Algebra and Geometry Review (61 topics, no due date)

Chapter 3 Vectors. m = m1 + m2 = 3 kg + 4 kg = 7 kg (3.1)

Right Triangles 4 A = 144 A = A = 64

GEOMETRY COMMON CORE STANDARDS

alternate interior angles

(15.) To find the distance from point A to point B across. a river, a base line AC is extablished. AC is 495 meters

Circle Name: Radius: Diameter: Chord: Secant:

Selected practice exam solutions (part 5, item 2) (MAT 360)

Section 9.1 Vectors in Two Dimensions

Vector Algebra II: Scalar and Vector Products

Part 1: Background - Graphing

Math, Trigonometry and Vectors. Geometry. Trig Definitions. sin(θ) = opp hyp. cos(θ) = adj hyp. tan(θ) = opp adj. Here's a familiar image.

INTERESTING PROOFS FOR THE CIRCUMFERENCE AND AREA OF A CIRCLE

Calculating Astronomical Unit from Venus Transit

Georgia Standards of Excellence Curriculum Map. Mathematics. GSE 8 th Grade

Evaluating trigonometric functions

1. Introduction sine, cosine, tangent, cotangent, secant, and cosecant periodic

Lesson 33: Example 1 (5 minutes)

Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

Warm-up Tangent circles Angles inside circles Power of a point. Geometry. Circles. Misha Lavrov. ARML Practice 12/08/2013

Chapter 10 Rotational Motion. Copyright 2009 Pearson Education, Inc.

Definitions, Postulates and Theorems

Universal Law of Gravitation

2-1 Position, Displacement, and Distance

Name: Class: Date: Multiple Choice Identify the choice that best completes the statement or answers the question.

Understanding Basic Calculus

Mechanical Principles

sin(θ) = opp hyp cos(θ) = adj hyp tan(θ) = opp adj

Mathematics. GCSE subject content and assessment objectives

Transcription:

1. Objective University of Cincinnati Department of Electrical & Computer Engineering and Computer Science 20 ENFD 112 Fundamentals of Programming Laboratory 2: Modeling, Scripting, Visualization Spring 2008 The purpose of this assignment is to perform some elementary modeling involving well-known trigonometric and geometric relations and to use MATLAB to visualize the use of the model. The student will program an elementary MATLAB script which will take user input, so some elementary processing on that input, and produce and display a visual result that is comprehensible. 2. MATLAB Scripting: Input, Process, Output Create a MATLAB script with the following characteristics: 1. Input: The user is prompted for four numbers. Each will be interpreted as the radius of a circle. An example of user input is the following: Circle 1 radius> 5.78 Circle 2 radius> 10.3 Circle 3 radius> 4 Circle 4 radius> 8.1 where numbers are entered by the user through a series of keystrokes involving keys 0 to 9 and. and ended by pressing the enter key. Strings such as Circle 1 radius> are prompts that your script displays when it is ready to receive input for a circle. 2. Process: The script will find the coordinates of the centers for the four circles so that (a) Circle 1 and Circle 3 are tangent to each other at the origin with Circle 1 on the left. (b) The centers of Circle 1 and Circle 3 are on the x axis (c) Circle 2 is tangent to Circle 1 and Circle 3 and its center above the x axis (d) Circle 4 is tangent to Circle 1 and Circle 3 and its center below the x axis. 3. Output: Plot these circles together with 6 straight lines connecting the centers of the circles. An example is shown in Figure 1. 3. Analysis and Assistance The coordinates of a point in the plane will be represented as a pair x,y where x is the horizontal displacement of the point from the origin and y is the vertical displacement of the point from the origin. If x is positive, the displacement is above the origin and if x is negative, it is below. Similarly for y. The origin has coordinates 0,0. Let r 1,r 2,r 3,r 4 be the radii of Circle 1, Circle 2, Circle 3, and Circle 4, respectively. The coordinates of the center of Circle 1 are then r 1,0 and of the center of Circle 3 r 3,0 as shown. To find the coordinates of the centers we must derive a relationship between their horizontal and vertical displacements and the distances between centers, which are known quantities.

Figure 1: Output from the MATLAB program. This relationship may be derived easily with the help of Figure 2 which shows a triangle with points A, B, C, sides of length a, b, c, and base AC. We need to determine the value of unknowns h and a 2 as a function of the knowns a, b, c. The expression we derive will be used to determine the coordinates of the centers of Circles 2 and 4 since a, b, and c will be distances between centers (sums of radii). By the theorem of Pythagoras, h 2 + a 2 2 = c 2 h 2 + a 2 1 = b 2 Subtracting the second equation from the first gives a 2 2 a2 1 = c2 b 2 Since a 1 + a 2 = a, we can substitute a a 2 for a 1, and rearrange, to get a 2 2 = c 2 b 2 + (a a 2 ) 2 = c 2 b 2 + a 2 2aa 2 + a 2 2 Subtracting a 2 2 from both sides, rearranging, and dividing both sides by 2a results in a 2 = (c 2 + a 2 b 2 )/2a. From trigonometry, so, cos(< BCA ) = a 2 /c sin(< BCA ) = h/c h = c. sin(cos 1 ((c 2 + a 2 b 2 )/2ac))

Figure 2: A triangle with sides of length a, b, and c. The side AC is the base of the triangle. In the text the height h at B (the distance from B to the base AC) and the distance a 2 (the horizontal distance from C to the vertical line passing through B) are computed in terms of the angle BCA. To see how to use these results, consult Figure 3 where the coordinates x 2,y 2 of the center of Circle 2 are found. Distance d 2,3 (corresponding to c in the triangle of Figure 2) is the sum of the radii of Circles 2 and 3 which is r 2 +r 3. Distance d 1,2 (corresponding to b in the triangle of Figure 2) is the sum of the radii of Circles 1 and 2 which is r 1 + r 2. The distance between centers of Circles 1 and 3 (corresponding to a in the triangle of Figure 2) is r 1 + r 3. The distance corresponding to a 2 in Figure 2 is r 3 x 2. Therefore y 2 = (r 2 + r 3 ). sin(cos 1 (((r 2 + r 3 ) 2 + (r 1 + r 3 ) 2 (r 1 + r 2 ) 2 )/2(r 2 + r 3 )(r 1 + r 3 ))) x 2 = r 3 (((r 2 + r 3 ) 2 + (r 1 + r 3 ) 2 (r 1 + r 2 ) 2 )/2(r 1 + r 3 )) The scripts in Figures 4 to 9 should be major hints in coding a solution to this problem. These scripts show how to draw lines and circles with given centers. The last figure shows how to obtain the center of circle 2. You will have to figure out how to obtain the center of circle 4. 4. Submission Submit the single m file requested in Section 2 on or before April 13 using blackboard. See the course webpage at http://gauss.ececs.uc.edu/courses/html/e112.html for instructions.

Figure 3: Calculation of the center coordinates of Circle 2.

% PlotCircle_0.m: Draw a circle of radius 1 centered at the origin % Drawing is a set of lines between points: the more points, the % better approximation to a circle. % Input: number of points n = input( Enter number of points: ); R = 1; % Unit radius x1 = R*cos(angle); y1 = R*sin(angle); % Set a point at angle x2 = R*cos(angle+2*pi/n); y2 = R*sin(angle+2*pi/n); % Set the next point line([x1 x2], [y1 y2]); % Draw the lines Figure 4: Script for drawing an approximation to a circle of radius 1 with a series of lines. The more lines, the better the approximation. The number of lines is input parameter n. Lines are drawn between pairs of points that are distance 1 from the origin at angles specified by vector angle which is created from. All angles in angle are uniformly spaced from 0 to 2π radians. The functions sin and cos are used to get the x and y coordinates of a point. % PlotCircle_1.m: Plot a circle of radius 1 centered at the origin % Input: number of points n = input( Enter number of points: ); R = 1; % Unit radius x = R*cos(angle); y = R*sin(angle); % Coordinates of the circle plot(x,y); % Plot the circle Figure 5: Alternative script for drawing an approximation to a circle of radius 1 with a series of lines. This time plot is used to draw the lines. All other considerations are the same as in Figure 4.

% PlotCircle_2.m: Plot a circle of radius 1 with specified center % Drawn circle is approximated by lines drawn between 50 points % Input: x and y coordinates specifying center of circle cx = input( Enter x coordinate of circle center: ); cy = input( Enter y coordinate of circle center: ); n = 50; R = 1; % 50 point approximation % Unit radius x = cx+r*cos(angle); y = cy+r*sin(angle); % Coordinates of circle plot(x,y); % Plot the circle Figure 6: Script for drawing an approximation to a circle of radius 1 centered at a specified point. The x and y coordinates of the center are obtained via console input. % PlotCircle_3.m: Plot two circles of specified radius that are tangent % to each other at the origin and whose centers lie on the x axis. % First circle (radius R1) will have its center to the left of the % origin. Drawn circle is approximated by lines drawn between 50 % points. A single call to plot is used: plot chooses different % colors for the circles. % Input: radii R1 and R2 of two circles R1 = input( Enter radius of first circle: ) ; R2 = input( Enter radius of second circle: ) ; n = 50; % 50 point approximation x1 = -R1+R1*cos(angle); y1 = R1*sin(angle); % Coordinates of circle 1 x2 = R2+R2*cos(angle); y2 = R2*sin(angle); % Coordinates of circle 2 plot(x1,y1,x2,y2); % Draw all circles axis equal ; Figure 7: Script for drawing two circles of specified radius that are tangent to each other at the origin and whose centers lie on the x axis. The radii of the circles are obtained via console input.

% PlotCircle_4.m: Alternative to PlotCircle_3.m. A call to plot is used % for each circle (two calls total). Color choices are made within % the arguments of plot. The purpose of hold on is to prevent % the second circle from erasing the first circle. % Input Radii R1 and R2 of two circles R1 = input( Enter radius of circle 1: ) ; R2 = input( Enter radius of circle 2: ) ; hold on; n = 50; % do not erase any circles % 50 points approximation x1 = -R1+R1*cos(angle); y1 = R1*sin(angle); % Coordinates of circle 1 plot(x1,y1, color,[1 0 0]); % Draw circle 1 red x2 = R2+R2*cos(angle); y2 = R2*sin(angle); % Coordinates of circle 2 plot(x2,y2, color,[0 1 0]); % Draw circle 2 green Figure 8: Alternative to Figure 7 differing in the use of two calls to plot, one for each circle, and in the specification of circle colors.

% PlotCircle_5.m: Plot two circles (circles 1 and 3 with radii R1, R3) % tangent to each other at the origin with centers on the x axis % and a third circle (circle 2 with radius R2) tangent to and above % circles 1 and 3. % Input Radii R1, R2, and R3 of three circles R1 = input( Enter radius of circle 1: ); R2 = input( Enter radius of circle 2: ); R3 = input( Enter radius of circle 3: ); hold on; n = 50; % do not erase drawn circles % 50 point approximation % Find center of circle 2 (tangent to and above circles 1 and 3) g = ((R2+R3)^2+(R1+R3)^2-(R1+R2)^2)/(2*(R1+R3)); % temporary variable cx2 = R3-g; % x coordinate of circle 2 center cy2 = (R2+R3)*sin(acos(g/(R2+R3))); % y coordinate of circle 2 center % Draw the circles x1 = -R1+R1*cos(angle); y1 = R1*sin(angle); % Coordinates of circle 1 plot(x1,y1, color,[1 0 0]); % Draw circle 1 red x2 = cx2+r2*cos(angle); y2 = cy2+r2*sin(angle); % Coordinates of circle 2 plot(x2,y2, color,[0 1 0]); % Draw circle 2 green x3 = R3+R3*cos(angle); y3 = R3*sin(angle); % Coordinates of circle 3 plot(x3,y3, color,[0 0 1]); % Draw circle 3 blue Figure 9: Script for drawing two circles with radii R1 and R3, that are tangent to each other at the origin with the R1 circle centered on the x axis to the left of the origin and the R2 circle centered on the x axis to the right of the origin, and a third circle with radius R2 that is tangent to and above the other two circles.