answersLogoWhite

0


Best Answer

private static void isInRectangle(int x, int y)

{

return (x <= xmax) && (x >= xmin) && (y <= ymax) && (y >= ymin);

}

User Avatar

Wiki User

16y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Let a rectangle that is align with the coordinate axes be represented by the coordinates of its lower left and upper right corners xmin ymin and xmax ymax. then abis outside or inside the rectangle?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the program to find the area of polygons using c plus plus?

#include&lt;iostream&gt; #include&lt;vector&gt; #include&lt;assert.h&gt; // Typdefs to hide unnecessary implementation detail and remove verbosity. using Coordinates = std::pair&lt;int,int&gt;; using Polygon = std::vector&lt;Coordinates&gt;; // Calculate the area of a given polygon. int area (const Polygon&amp; polygon) { // The given polygon must list all vertices in the correct sequence // either clockwise or anti-clockwise. It does not matter which // vertex begins the sequence, but the last vertex is assumed to // join the first. // Initialise an accumulator. int accumulator = 0; // A polygon with less than 3 vertices is no polygon! if (polygon.size() &lt; 3) return accumulator; // The last vertex is the previous vertex to the first vertex. // We'll deal with this specific pair of vertices first. size_t previous = polygon.size() - 1; // Iterate through all vertices in sequence. for (size_t current=0; current&lt;polygon.size(); ++current) { // The previous and current vertices form an edge. We need to calculate // the area of the imaginary rectangle extending horizontally from this // edge until it meets the Y-axis. This edge may not be vertical so we // also extend in the opposite direction by the same amount. That is, // for vertices {x1, y1} and {x2, y2}, the imaginary rectangle's opposing // corners will be at imaginary vertices {0, y1}, {x1+x2, y2}. The area // of this imaginary rectangle is therefore (x1+x2)*(y1-y2). // Note: the imaginary rectangle's area may be negative but that's OK. // It'll simply be subtracted from the accumulator and that's exactly // what we want. accumulator += (polygon[previous].first + polygon[current].first) * (polygon[previous].second - polygon[current].second); // The current vertex now becomes the previous vertex // in readiness for the next iteration. previous = current; } // Remove the sign (make absolute). accumulator *= (accumulator&lt;0) ? -1 : 1; // At this point the accumulated total is guaranteed to be an even // number (as we'll see). But let's play safe and assert that fact. assert (accumulator % 2 == 0); // Since each imaginary rectangle was exactly double what we needed // (because we extended in both directions), divide the accumulated // total by 2. It's more efficient to do that here, once, rather // than for each individual rectangle. We don't have to worry about // fractions since the accumulator is guaranteed to be even. return accumulator / 2; } // Driver to test the function. int main() { Polygon square; square.push_back (Coordinates (0, 0)); square.push_back (Coordinates (0, 10)); square.push_back (Coordinates (10, 10)); square.push_back (Coordinates (10, 0)); assert (area (square) == 100); std::cout &lt;&lt; "Square (10 x 10) has area " &lt;&lt; area (square) &lt;&lt; std::endl; Polygon triangle; triangle.push_back (Coordinates (0, 0)); triangle.push_back (Coordinates (0, 6)); triangle.push_back (Coordinates (8, 0)); assert (area (triangle) == 24); std::cout &lt;&lt; "Right-angled triangle (width 8, height 6) has area " &lt;&lt; area (triangle) &lt;&lt; std::endl; Polygon irregular; irregular.push_back (Coordinates (0, 0)); irregular.push_back (Coordinates (0, 14)); irregular.push_back (Coordinates (8, 14)); irregular.push_back (Coordinates (8, 4)); irregular.push_back (Coordinates (12, 4)); irregular.push_back (Coordinates (12, 0)); assert (area (irregular) == 128); std::cout &lt;&lt; "6-sided irregular polygon has area " &lt;&lt; area (irregular) &lt;&lt; std::endl; Polygon line; line.push_back (Coordinates (0, 0)); line.push_back (Coordinates (0, 4)); line.push_back (Coordinates (0, 8)); assert (area (line) == 0); std::cout &lt;&lt; "3 points on a line of length 8 has area " &lt;&lt; area (line) &lt;&lt; std::endl; }


Do all squares have corners?

Yes squares ALWAYS have corners but they can be a sharp point or a very slightly rounded edge. Hope this helps!!


How many studs are in a 40 foot wall?

31 Studs not counting corners


How many sides does a cubiod have?

it ha 6 faces 12 edges 8 (corners)


What is a bevel edge?

A bevel edge is slanted from the perpendicular, like a board with the corners shaved off.

Related questions

Are the midpoints the vertices of a rectangle?

No- the vertices of a rectangle are the four coordinates (corners) not the midpoints.


What are the coordinates of the center of a rectangle?

Just find the midpoint of opposite corners Consider the rectangle with sides of length a and b. The length of a diagonal is then sqrt(a2+b2) The two diagonals cross at the midpoint or where the length of the line from one vertex to the center is one half of a diagonal or (0.5)[sqrt(a2+b2)]. 1- Consider you have Point A(XA,YA) corresponding to the upper left coordinate of the rectangle and you have Point B(XB, YB) corresponding to the lower right coordinate of the rectangle, then, coordinates of the center Point C (XC, YC) is calculated: XC = XA + (XB-XA)/2 YC = YA - (YA-XB)/2 2- Consider you have Point A(XA,YA) corresponding to the upper left coordinate of the rectangle and the width (W) and height (H) of the rectangle, then, coordinates of the center Point C (XC, YC) is calculated: XC = XA + (W)/2 YC = YA - (W)/2


How many rectangle has corner?

Every rectangle must have corners otherwise it would not be a rectangle!Every rectangle must have corners otherwise it would not be a rectangle!Every rectangle must have corners otherwise it would not be a rectangle!Every rectangle must have corners otherwise it would not be a rectangle!


How many corners in a rectangle?

There are 4 corners in a flat rectangle and 8 corners in a 3d rectangle(rectangular prism).Four.


How many corners does a rectangle have?

A rectangle is a quadrilateral therefore it has to have 4 corners.


Why is a rectangle a rectangle?

The name rectangle refers to the right-angled corners. A rectangle is a four-sided shape with right-angled corners.


HOw many corners does a 3d rectangle have?

A 3d rectangle, or a cuboid, has eight corners.


How many corner in rectangle?

There are 4 corners in a flat rectangle and 8 corners in a 3d rectangle(rectangular prism).Four.


Three corners of a rectangle, the dog park are located at (-2,1) (-2,3) and (5,3) on a coordinate plane. What is the total length of the fencing that is needed to enclose the dog park?

21


What is a parallelogram with 4 square corners?

A rectangle.


Where is the angle on a rectangle?

It is one of the four corners of a rectangle.


How many corners does a reactangle have?

A rectangle has four corners, or vertices