How to connect PC and Mac directly via Wi-fi?

2,003

Setup an Ad-Hoc network, one system, join it from the other.

First system setup:

Share:
2,003

Related videos on Youtube

Brieg
Author by

Brieg

Updated on September 18, 2022

Comments

  • Brieg
    Brieg almost 2 years

    How to draw circle or semi circle or arc from start(B) to end(C) point giving(without using any external library) in pure C# and OpenGL :

    • A(Ax,Ay) - polyline
    • B(Bx,By) - start point
    • C(Cx,Cy) - end point
    • M(Mx,My) - center of circle or semi circle or arc
    • r - radius
    • startAngle = atan2(B.y - M.y, B.x - M.x) - in radians
    • endAngle = atan2f(C.y - M.y, C.x - M.x) - in radians
    • segments = 80

    Unknow values:

    • clockwise or anticlockwise direction

    Requirements

    • Arc must be drawing from point B to C

    Can someone please provide me equation for drawing an arc in OpenGL?

    Hint:

    Will it be a circle, a semicircle or arc it depends on the position of the center of the circle and the start and end points.

    Please give me a some light to solve this.

    -- EDIT --

    Below i present the solution. But it draw sometimes in wrong direction (should clockwise but it draw anticlockwise).:

    enter image description here

    float startAngle = atan2(B.y - centerArc.y, B.x - centerArc.x);
    float endAngle = atan2(C.y - centerArc.y, C.x - centerArc.x);
    
    if (endAngle < startAngle)
    {
        endAngle += 2.0f * PI;
    }
    
    glBegin(GL_LINE_STRIP);
    for (float angle = startAngle; angle <= endAngle; angle = angle + 0.01f)
    {
        float x = centerArc.x + cos(angle) * r;
        float y = centerArc.y + sin(angle) * r;
        glVertex2f(x, windowHeight - y);
    }
    glEnd();
    

    It gives: enter image description here

    • BDL
      BDL almost 8 years
      Haven't you asked the same question several times?
    • Brieg
      Brieg almost 8 years
      In Java or Android with ready libraries, yes.
    • Unick
      Unick almost 8 years
      Try to call glDisable​(GL_CULL_FACE) before render. Maybe it is turned on by default.
    • Nicol Bolas
      Nicol Bolas almost 8 years
      "Semi circle have to be bottom of the line and not on the top." Bottom relative to what? Lines do not have a "bottom" or a "top". So how do you determine which side of the line you want the arc drawn on?
    • Martijn Pieters
      Martijn Pieters almost 8 years
      Please don't vandalise your post please.
  • BDL
    BDL almost 8 years
    I do not exactly understand what you mean.
  • BDL
    BDL almost 8 years
    I see. The problem is, that the angles are in range from -pi to pi and you are not taking that into account. The easiest thing is to move add 2*pi to the angle when it is negative.
  • BDL
    BDL almost 8 years
    Exchanging B and C should do the trick. When B->C is the counter-clockwise part, then C->B will be the other direction.
  • BDL
    BDL almost 8 years
    how do you even know which orientation you want? Your problem is under-determined when not fixing the orientation. Unless you have any other constraint to determine the direction, I don't see any way how to do this. And it would make the world for both of us easier when you start with the full set of information on first place.
  • BDL
    BDL almost 8 years
    As already said: From the data you have, you will not be able to conclude which orientation is the right one. You could decide it depending on the line segment before the arc starts, but this would require at least on additional point.
  • Brieg
    Brieg almost 8 years
    Please remove this topic. Thx.