One quadrant multiplier and Four quadrant multip - electronic-signature

I am studying Advance electronics subject and i came across topics one quadrant multiplier and four quadrant multiplier. What i can't understand is that how one quadrant multiplier can operate on only when both inputs are positive (eg: +2 and +1 ) but cannot operate when input voltages are both negative and opposite polarity (+-, -+, --) and four quadrant multiplier can operate on all four possible input values (++, -+ ,+-, --). I will be very happy for your explanation. Thank you.
[Four quadrant multiplierone quadrant multiplier](https://i.stack.imgur.com/Bkg2H.jpg)
I just don't understand how one quadrant multiplier cannot operate when inputs are +-, -+ or --. I just want explanation how it cannot operate on these values and also how four quadrant multiplier can operate on those values.

Related

Minimize room size for social distancing

I have to minimize the area of a squared room to keep a 2-meter distance between n people. How could I model the problem?
A very simple approach would be
Introduce a variable p_x and p_y for each person p. This gives the position of the person in the room.
minimize (max(p_x) - min(p_x)) * (max(p_y) - min(p_y)) (the area). For a squared room you would have to minimize max((max(p_x) - min(p_x)), (max(p_y) - min(p_y))) ^ 2.
the constraint is that for any two persons p1 and p2 the distance between (p1_x, p1_y) and (p2_x, p2_y) is at least 2 metres.
Note that what you are trying to do is related to "circle packing" or "disk packing": each person can be represented as a disk with radius 1m and you are looking for the smallest rectangle into which all disks can be packed. You may check out this problem and how it is modeled/solved.

Computing Minkowski Difference For Circles and Convex Polygons

I'm needing to implement a Minkowski sum function that can return the Minkowski sum of either 2 circles, 2 convex polygons or a circle and a convex polygon. I found this thread that explained how to do this for convex polygons, but I'm not sure how to do this for a circle and polygon. Also, how would I even represent the answer?! I'd like the algorithm to run in O(n) time but beggars can't be choosers.
Circle is trivial -- just add the center points, and add the radii. Circle + ConvexPoly is nearly as simple: move each segment perpendicularly outward by the circle radius, and connect adjacent segments with circular arcs centered at the original poly vertices. Translate the whole by the circle center point.
As for how you represent the answer: Well, it depends on what you want to do with it. You could convert it to a NURBS if you just want to draw it with a vector drawing library. You could approximate the circular arcs with polylines if you just want a polygonal approximation. Or you might store it as is -- "this polygon, expanded by such-and-such a radius". That would be the best choice for things like raycasting, for instance. Or as a compromise, you could connect adjacent segments linearly instead of with circular arcs, and store it as the union of the (new) convex polygon and a list of circles at the vertices.
Oh, about ConvexPoly + ConvexPoly. That's the trickiest one, but still straightforward. The basic idea is that you take the list of segment vectors for each polygon (starting from some particular extremal point, like the point on each poly with the lowest X coordinate), then merge the two lists together, keeping it sorted by angle. Sum the two points you started with, then apply each vector from the merged vector list to produce the other points.

Most efficient way to check if a point is in or on a convex quad polygon

I'm trying to figure out the most efficient/fast way to add a large number of convex quads (four given x,y points) into an array/list and then to check against those quads if a point is within or on the border of those quads.
I originally tried using ray casting but thought that it was a little overkill since I know that all my polygons will be quads and that they are also all convex.
currently, I am splitting each quad into two triangles that share an edge and then checking if the point is on or in each of those two triangles using their areas.
for example
Triangle ABC and test point P.
if (areaPAB + areaPAC + areaPBC == areaABC) { return true; }
This seems like it may run a little slow since I need to calculate the area of 4 different triangles to run the check and if the first triangle of the quad returns false, I have to get 4 more areas. (I include a bit of an epsilon in the check to make up for floating point errors)
I'm hoping that there is an even faster way that might involve a single check of a point against a quad rather than splitting it into two triangles.
I've attempted to reduce the number of checks by putting the polygon's into an array[,]. When adding a polygon, it checks the minimum and maximum x and y values and then using those, places the same poly into the proper array positions. When checking a point against the available polygons, it retrieves the proper list from the array of lists.
I've been searching through similar questions and I think what I'm using now may be the fastest way to figure out if a point is in a triangle, but I'm hoping that there's a better method to test against a quad that is always convex. Every polygon test I've looked up seems to be testing against a polygon that has many sides or is an irregular shape.
Thanks for taking the time to read my long winded question to what's prolly a simple problem.
I believe that fastest methods are:
1: Find mutual orientation of all vector pairs (DirectedEdge-CheckedPoint) through cross product signs. If all four signs are the same, then point is inside
Addition: for every edge
EV[i] = V[i+1] - V[i], where V[] - vertices in order
PV[i] = P - V[i]
Cross[i] = CrossProduct(EV[i], PV[i]) = EV[i].X * PV[i].Y - EV[i].Y * PV[i].X
Cross[i] value is positive, if point P lies in left semi-plane relatively to i-th edge (V[i] - V[i+1]), and negative otherwise. If all the Cross[] values are positive, then point p is inside the quad, vertices are in counter-clockwise order. f all the Cross[] values are negative, then point p is inside the quad, vertices are in clockwise order. If values have different signs, then point is outside the quad.
If quad set is the same for many point queries, then dmuir suggests to precalculate uniform line equation for every edge. Uniform line equation is a * x + b * y + c = 0. (a, b) is normal vector to edge. This equation has important property: sign of expression
(a * P.x + b * Y + c) determines semi-plane, where point P lies (as for crossproducts)
2: Split quad to 2 triangles and use vector method for each: express CheckedPoint vector in terms of basis vectors.
P = a*V1+b*V2
point is inside when a,b>=0 and their sum <=1
Both methods require about 10-15 additions, 6-10 multiplications and 2-7 comparisons (I don't consider floating point error compensation)
If you could afford to store, with each quad, the equation of each of its edges then you could save a little time over MBo's answer.
For example if you have an inward pointing normal vector N for each edge of the quad, and a constant d (which is N.p for one of the vertcies p on the edge) then a point x is in the quad if and only if N.x >= d for each edge. So thats 2 multiplications, one addition and one comparison per edge, and you'll need to perform up to 4 tests per point.This technique works for any convex polygon.

How to depict multidimentional vectors on two-dinesional plot?

I have a set of vectors in multidimensional space (may be several thousands of dimensions). In this space, I can calculate distance between 2 vectors (as a cosine of the angle between them, if it matters). What I want is to visualize these vectors keeping the distance. That is, if vector a is closer to vector b than to vector c in multidimensional space, it also must be closer to it on 2-dimensional plot. Is there any kind of diagram that can clearly depict it?
I don't think so. Imagine any twodimensional picture of a tetrahedron. There is no way of depicting the four vertices in two dimensions with equal distances from each other. So you will have a hard time trying to depict more than three n-dimensional vectors in 2 dimensions conserving their mutual distances.
(But right now I can't think of a rigorous proof.)
Update:
Ok, second idea, maybe it's dumb: If you try and find clusters of closer associated objects/texts, then calculate the center or mean vector of each cluster. Then you can reduce the problem space. At first find a 2D composition of the clusters that preserves their relative distances. Then insert the primary vectors, only accounting for their relative distances within a cluster and their distance to the center of to two or three closest clusters.
This approach will be ok for a large number of vectors. But it will not be accurate in that there always will be somewhat similar vectors ending up at distant places.

Mathematical technique to check intersection

Imagine there is a very very large room in the shape of a hollow cube. There are magic balls hanging in the air at fixed discrete positions of the room. No magic ball has another one exactly above it. If we take an imaginary horizontal plane of infinite area and pass through the cube, how can we be sure that the plane doesn't cut through any of the magic balls ?
The height of a magic ball is given as a function of its position (x and y). The distribution is such a way that some balls are at the same height while other are at different heights.
Let the function be
z = axy + bx + cy
where a,b,c are positive integer constants.
The positions (x-axis and y-axis values) and also the height (z) are discrete values (for simplicity, we can consider them positive integers).
If the ball distribution function was z=10xy+8x+4y, then it is impossible to have a z value of 15 or 21. So a plane at z=15 or z=21 would not cut any of the balls! In fact, in this case, any plane with a height (z = any odd number) would not cut through the balls. It is noticeable that there a some planes with height as even numbers that donot cut through the balls.
We do not want to find the heights of all the magic balls and compare it with the height of the horizontal plane, as that would be like trying all the possible combinations and would take very long time even on a computer.
Our aim is to find a fast method by which we can tell whether a given value of z (height) can be produced by any pair of (x,y) (positions).If a given z cannot be produced, then a plane at that height doesn't cut through any balls!
The question is also similar to finding whether a given number is present in a sequence produced by a function of two variables.
It would a great help if U could give me any suggestions to solve this problem. Thank You.
(I have already tried evolutionary computing like GA,PSO,DE,SA etc. The method needs to be deterministic).
It sounds like you have a lot of balls in the room. The room height is from z=A to z=B. What you're interested in is whether any are at height z. To do that without necessarily iterating through all the balls, you need to start by assuming that the range A to B is empty and iterate through the balls, marking parts of this range as full, until it is either full completely or there are no balls. In the former case, no plane will satisfy, but you haven't iterated through all the balls to know that. In the latter case, you have ranges of z in which there are no balls and you can use these to check more than one plane easily, however at the initial cost of iterating through all balls.