Who has a program to find the intersection of circles and straight line segments in OpenGL under C

Updated on educate 2024-04-03
11 answers
  1. Anonymous users2024-02-07

    Since it's opengl, it must be under the three-dimensional space coordinate system, which you can calculate by yourself using geometric methods, or you can use math libraries such as cgal, but the topic is not complicated, just write it yourself.

  2. Anonymous users2024-02-06

    Write it yourself.

    Spherical: (x-x0) 2 + y-y0) 2 + z-z0) 2 = r 2

    Straight line: (x-x1) a = y-y1) b = z-z1) c = k

    Substituting the square stroke of the straight line into the spherical surface solves the unary two-order equation.

  3. Anonymous users2024-02-05

    Now map the center of the ball to a straight line to get the vertical foot.

    To get the perpendicular segment, to get the length, using the Pythagorean Min Nianhuai theorem, to get the chord length.

    Use the vertical foot chord length to ask the bridge friend to erect the intersection point.

  4. Anonymous users2024-02-04

    First, analyze whether there is an intersection point.

    There is no intersection in the following cases:

    Two circles are too far apart (the distance between the centers of the circles is greater than the radius and the sum of the circles) and a circle is inside a circle.

    There are also several special cases:

    Tangent , there is only one focal point. It is divided into internal and external incision.

    If two circles are of the same size (same radius) and have the same coordinates at the center of the circle, then there are an infinite number of intersections.

    Then all that's left is to set the formula to calculate.

  5. Anonymous users2024-02-03

    Detailed insights into the law description and procedures.

  6. Anonymous users2024-02-02

    , find the coordinates of the intersection of the two circles, kneel down and beg the master to give a cc

  7. Anonymous users2024-02-01

    Determine whether the two segments are not parallel (it is better to determine if there is an intersection and not parallel at the same time, because the floating-point arithmetic is not accurate), and then calculate the intersection of the two segments. The following is the C language**:

    #include

    #include

    #define eps 1e-8

    #define zero(x) (x)>0?(x):-x))eps;

    The judgment is that the two straight lines are parallel.

    int parallel(point u1,point u2,point v1,point v2){

    return zero((;

    Three-point collinearity.

    int dots_inline(point p1,point p2,point p3){

    return zero(xmult(p1,p2,p3));

    Determine the intersection of two line segments, including endpoints and partial coincidence.

    int intersect_in(point u1,point u2,point v1,point v2){

    if (!dots_inline(u1,u2,v1)||dots_inline(u1,u2,v2))

    return dot_online_in(u1,v1,v2)||dot_online_in(u2,v1,v2)||dot_online_in(v1,u1,u2)||dot_online_in(v2,u1,u2);

    To calculate the intersection of two line segments, please determine whether the line segments intersect (and also determine whether they are parallel!). )

    point intersection(point u1,point u2,point v1,point v2){

    point ret=u1;

    double t=((

    ;;return ret;

    int main(void)

    point u1,u2,v1,v2,ans;

    printf("Please enter the two endpoints of line segment 1:");

    printf("Please enter the two endpoints of line segment 2:");

    if (parallel(u1,u2,v1,v2)||intersect_in(u1,u2,v1,v2)){

    printf("No intersections! ");

    else{ans=intersection(u1,u2,v1,v2);

    printf("The intersection is: (%lf,%lf).",,;

    return 0;

  8. Anonymous users2024-01-31

    vla-intersectwith seek, see cad help.

    vla-intersectwith e1 e2 no) ;no is the line that indicates whether to extend the intersection 0 3 .

    You can also find the distance from the center of the circle to the vertical line of the line, the perpendicular point, the known radius, and the angle of the line according to the most basic geometric method.

  9. Anonymous users2024-01-30

    I don't know, you will lisp, if you will, I can tell you the idea, I don't have time to write right now.

  10. Anonymous users2024-01-29

    You can first make these wireframes into regions, and then use the Region Merge command to merge regions. Then the total area comes out. It can be achieved without lisp.

  11. Anonymous users2024-01-28

    1. There is a problem with the state of the class point, and the x and y in it are private.

    2. The class line is not a friend of the point, and the setpoint is not a friend of the Ponit-like class, so it is impossible to access, 3. Solution: either add an interface to the x and y of the point, or change the access permission to public, or use the structure to declare the point.

Related questions
10 answers2024-04-03

You start by writing a function to find a sequence.

Then use for or while to call the !! >>>More

25 answers2024-04-03

First think about how many parts the whole program needs, and then what functions each part needs, and then think about the process of each part, the global variables needed, and then make it up according to the content of the design.

4 answers2024-04-03

The introductory course of MCU C language programming is not difficult, it is not easy to say, and the first thing to understand is to understand what these two things are when learning MCU C language? The introductory programming of single-chip microcomputer is mainly to learn C language, followed by circuit and programming language. >>>More

8 answers2024-04-03

Program Problem 1: include

int main(void) >>>More