0

I have a theoretically question. I have a circle with dynamically generated number of quadrants like in the picture. So there could be more or less quadrants then on the picture.

Now the question: How do I make it possible to rotate each quadrant, that one side is always parallel to the x-axis.

enter image description here

  • Question is not clear. – MBo Jan 07 '21 at 17:04
  • You have an example Quadrant from point A to F to E to A again.The side A F or A E should always be parrallel to the x axis. How do I calculate this for all Quadrants? If you have specific questions you are welcome to ask. – Severin Koch Jan 08 '21 at 19:25
  • @SeverinKoch In your example `AE` looks to be vertical, so a rotation of `π/2` will make it horizontal. In the general case, calculate the slope of `AE` using [`atan2`](https://en.wikipedia.org/wiki/Atan2) for example, then rotate by the opposite angle. – dxiv Jan 09 '21 at 03:25
  • use [parametric circle equation and start from `angle = 0.0` [rad] with increment `2.0*Pi / n` [rad] where `n` is the number of pie sections ("quadrants") – Spektre Jan 09 '21 at 11:20
  • @spektre I like you approach. However how can I create a Formula that uses different formula for diffferent Quadrants. For the first 2 Quadrants I have to use (90 - 2.0*PI / n), for the third quadrant (2* 90 - 2.0 * PI / n) and for the 4,5 quadrant - (90 - 2.0* PI / n), because of opposite direction. This is only for a 5 Quadrants circle, thus I cant use if-statements. I have read something about Transformation-matrix not sure if that fits. – Severin Koch Jan 12 '21 at 09:20
  • why do you want to have different formulas ? all "quadrants" should have the same... for example `a = i*2.0*PI/n; x = x0+r*cos(a); y = y0+r*sin(a);` where `i` is the "quadrant" if you want negative direction of angle then use `a = -i*2.0*PI/n;` and that is it. The `x0,y0` is center of your circle and `r` its radius. If your points are not in order than just create LUT with their order instead of hardcoding equations. The [transform matrices](https://stackoverflow.com/a/28084380/2521214) are overkill for this. – Spektre Jan 12 '21 at 09:52
  • Also see this [Generate a “pieslice” in C without using the pieslice() of graphics.h](https://stackoverflow.com/a/58246614/2521214) on how to manage the "quadrants" operations like is point inside or not ... easily and fast – Spektre Jan 12 '21 at 09:56
  • If I take the circle equation. than I have the coordiantes with the angle a. Then I could use atan2 to calculate the angle between the point and the x achsis? I tried but It doesnt work properly. I might have to spend some more time. – Severin Koch Jan 12 '21 at 11:59
  • @SeverinKoch `atan2` must work however you need to check if your angles are in `[rad]` or `[deg]` and also check the output range of the `atan2` ... it might be `<-Pi,+PI>` instead of `<0,2*PI>` which might be the source of your problem. Also to check in which pie slice a point is you do not need `atan2` ... its enough to use vectors and cross product exactly like I do in the link above... if you got more concentric circles slicing your pies into more layers then you need to add also radius check (distance from center) – Spektre Jan 13 '21 at 08:36
  • @SeverinKoch My bet is You most likely messed something in code (which you did not provide so we can only guess) – Spektre Jan 13 '21 at 08:38

0 Answers0