Write the function signedArea that takes three parameters A, B, and C, representing the three vertices...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write the function signedArea that takes three parameters A, B, and C, representing the three vertices of an oriented triangle, and returns the signed area of the triangle ABC. Each parameter is a tuple of 2 floats, representing a point in 2-space. 2-space is our term for two dimensional space, like the floor of your room, but a really large room. The signed area of the oriented triangle ABC in 2-space is the area of the triangle, but positive if ABC defines a left turn (counterclockwise) and negative if ABC defines a right turn (clockwise). For example, if A=(1,1), B=(3,1), C=(3,2), then the signed area of the triangle ABC is 1.0, and the signed area of the triangle ACB is -1.0. 2 To calculate the signed area of the triangle ABC, use the following facts. The vector between two points P and Q is Q - P (component-wise subtraction: for example, (2,1) - (.5,.3) is (1.5,.7)). The signed area of the triangle spanned by vectors V = (vo, v₁) and W = (wo, W₁) is vo*w1_v1*° Another way of thinking of this result: if we let O = (0, 0) be the origin in 2-space, P = (Po, P₁) and Q (90,91) be arbitrary points in 2-space, then the signed area of the triangle OPQ is Po*q1p1*qo Note: this function allows you to determine whether you are turning left or right as you move around a polygon (how?). This will be useful later in the Graham scan algorithm for computing the convex hull of a polygon. = 2 areaPolygon (p) Write the function areaPolygon that takes a list p of tuples, representing the vertices of a polygon, sorted counterclockwise around the polygon, and returns the area of the polygon. The area of a polygon may be decomposed into the sum of the signed areas of a collection of triangles built by walking around the polygon. In particular, if the polygon vertices moving counterclockwise around the polygon are po, P1,..., Pk and if O is the origin (0,0) in 2-space, then the polygon area is the sum of the signed areas of the triangles Opop1, Op1P2,..., OpkPo. (If you walk around the polygon in the clockwise direction, then the sum of the signed areas will be the negative area of the polygon.) Your code should use the signedArea function you designed above. We will explain why this works in lecture. Note: It turns out that you could replace the origin O by any other fixed point in 2-space: choosing the origin simplies the computation. See over for additional context on the improveFilename function. Write the function signedArea that takes three parameters A, B, and C, representing the three vertices of an oriented triangle, and returns the signed area of the triangle ABC. Each parameter is a tuple of 2 floats, representing a point in 2-space. 2-space is our term for two dimensional space, like the floor of your room, but a really large room. The signed area of the oriented triangle ABC in 2-space is the area of the triangle, but positive if ABC defines a left turn (counterclockwise) and negative if ABC defines a right turn (clockwise). For example, if A=(1,1), B=(3,1), C=(3,2), then the signed area of the triangle ABC is 1.0, and the signed area of the triangle ACB is -1.0. 2 To calculate the signed area of the triangle ABC, use the following facts. The vector between two points P and Q is Q - P (component-wise subtraction: for example, (2,1) - (.5,.3) is (1.5,.7)). The signed area of the triangle spanned by vectors V = (vo, v₁) and W = (wo, W₁) is vo*w1_v1*° Another way of thinking of this result: if we let O = (0, 0) be the origin in 2-space, P = (Po, P₁) and Q (90,91) be arbitrary points in 2-space, then the signed area of the triangle OPQ is Po*q1p1*qo Note: this function allows you to determine whether you are turning left or right as you move around a polygon (how?). This will be useful later in the Graham scan algorithm for computing the convex hull of a polygon. = 2 areaPolygon (p) Write the function areaPolygon that takes a list p of tuples, representing the vertices of a polygon, sorted counterclockwise around the polygon, and returns the area of the polygon. The area of a polygon may be decomposed into the sum of the signed areas of a collection of triangles built by walking around the polygon. In particular, if the polygon vertices moving counterclockwise around the polygon are po, P1,..., Pk and if O is the origin (0,0) in 2-space, then the polygon area is the sum of the signed areas of the triangles Opop1, Op1P2,..., OpkPo. (If you walk around the polygon in the clockwise direction, then the sum of the signed areas will be the negative area of the polygon.) Your code should use the signedArea function you designed above. We will explain why this works in lecture. Note: It turns out that you could replace the origin O by any other fixed point in 2-space: choosing the origin simplies the computation. See over for additional context on the improveFilename function.
Expert Answer:
Related Book For
Fundamentals Of Electric Circuits
ISBN: 9780073301150
3rd Edition
Authors: Matthew Sadiku, Charles Alexander
Posted Date:
Students also viewed these programming questions
-
What are 3 foreseeable risks that exist in lacrosse? What is the probability and likelihood that each of these risks could actually occur?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
In Exercises 1126, determine whether each equation defines y as a function of x. x + y = 16
-
Determine by direct integration the moment of inertia of the shaded area with respect to the x axis. y = ke-via
-
Using Masons rule, find the transfer function, T(s) = C(s)/R(s), for the system represented in Figure P5.22. G|(s) G(s) G3(s) G,(s) Rs) C(s) -1 -1 -1 FIGURE P5.22
-
Consider the property valuation data found in Table B.4. a. Use the all-possible-regressions method to find the "best" set of regressors. b. Use stepwise regression to select a subset regression...
-
Blue Wave Co. predicts the following unit sales for the coming four months: September, 4,000 units; October, 5,000 units; November, 7,000 units; and December, 7,600 units. The companys policy is to...
-
Beginning Investment in the business: The owner of the company has invested $18,000 cash into the business. This increases the assets of the business from its zero balance. Owner's equity also...
-
The click throughs obtained for Eltronix Inc during an eight-week period are provided in the table below. Eltronix ran a branded keyword search campaign in the first four weeks at a CPC of $0.15....
-
1. Identify some ways in which the leadership experiences of women, non-White, or LGBTQ leaders are different from that of heterosexual White men? 2. Is there a feminine advantage? Do women leaders...
-
What is the length of an 16 penny nail used to nail sheathing to a joist or a stud?
-
Mission 1. What is a mission within a school? 2. Provide an example of a school mission 3. Please add how this mission is reflected (opening doors, manners etc)
-
8. (5 points) Give big-O bounds for T(n) in each of the following recurrences. Use induction, iteration or Master Theorem. 8a) T(n) = 2T(n/8)+n T(n)T(n-2)+n 8b) 8c) T(n)=7T(n/3) + n
-
Nardin Outfitters has a capacity to produce 12,000 of their special arctic tents per year. The company is currently producing and selling 5,000 tents per year at a selling price of $900 per tent. The...
-
The following information relates to the only product sold by Mastrolia Manufacturing: Sales price per unit Variable cost per unit Fixed costs per year Required: $ 120 72 800,000 a. Compute the...
-
Nature of light Q. Why corpuscular theory was rejected?
-
Danielle has an insurance policy with a premium of $75 per month. In September she is in an accident and receives a bill worth $2990 for the repair of her own property. Her deductible is $250 and her...
-
Determine v0 (t) for t > 0 in the circuit of Fig. 7.139. Let is = 10u(t) μ A and assume that the capacitor is initially uncharged. 10 kS2 50 k
-
Find v 0 (t) in the circuit of Fig. 16.54 if v x (0) = 2 V and i(0) = 1A. 1 F e u(t) A
-
For the circuit in Fig. 7.113, is(t) = 5u(t) Find v(t). 2 6 0.25 F
-
Attach LEDs to your system bus so that you can monitor its activity. For example, use an LED to monitor the read/write line on the bus.
-
Describe the role of these signals in a bus: a. R/W b. data ready c. clock
-
Draw a UML sequence diagram that shows a four-cycle handshake between a bus master and a device.
Study smarter with the SolutionInn App