Finding Points Using Trigonometry

Finding Points Using Trigonometry
Site menu


Login form


Search


Site friends
  • Create your own site


  • Statistics

    Total online: 1
    Guests: 1
    Users: 0


    Welcome, Guest ยท RSS 16 September 2024
    Finding Points Using Trigonometry


    At this point, we have all the known points we can obtain without utilizing some math. ultimately, we want to find the intersection


    point between the circle and the cut axis. By using the basic trigonometric functions, we can derive the relationship between the sides
    of triangle. In particular, we want to look for triangles that contain right angles. If we analyze the known elements to our problem, we can see that two triangles can be used to find one intersection on the circle (See figure 6.14)

    Figure 6.14: Triangles used to find the intersection


    In our analysis, we see that we can find a point along the cut axis that describes the corner of a right triangle. To find this point, we only need an angle and the length of the hypotenuse of the triangle. We can then apply one of the basic trigonometric functions shown in figure 6.15 to our problem.

    Figure 6.15: Basic trigonometric functions

    The sine function is the best match to information we have.


    sine(angle) = opposite side / hypotenuse
    This formula has to be modified using some basic algebra to suite our needs:
    opposite side = hypotenuse * sine (angle)
    Before we can use the sine function, we need to find the angle formed by points lpt1, lpt2 and cent (see figure 6.16).
    Figure 6.16: Angle needed to before the sine function can be used.

    The following function does this for us:

    (setq ang1 (- (angle lpt1 cent) (angle lpt1 lpt2)))

    The first of these three functions finds the angle described by points lpt1 and lpt1. The second expression finds the angle from lpt1 to
    the center of the circle. The third line finds the difference between these two angles to give us the angle of the triangle we need (see
    figure 6.17).


    Figure 6.17: The sine expression written to accommodate the known elements.

    We also need the length of the hypotenuse of the triangle. this can be gotten by finding the distance between lpt1 and the center of the
    triangle:

    (setq dst1 (distance lpt1 cent))

    The length of the hypotenuse is saved as the variable dst1. We can now apply our angle and hypotenuse to the formula:
    opposite side = hypotenuse * sine (angle) becomes

    (setq dst2 (* dst1 (sin ang1)))

    Now we have the length of the side of the triangle but we need to know the direction of that side in order to find the corner point of the
    triangle. We already know that the direction is at a right angle to the cut axis. therefore, we can determine the right angle to the cut axis
    by adding the cut axis angle to 1.57 radians (90 degrees)(see figure 6.18). The following expression does this for us:

    (setq ang2 (- (angle lpt1 lpt2) 1.57))


    Figure 6.18: Finding the angle of the opposite side of the triangle.

    We are now able to place the missing corner of the triangle using the polar function (see figure 6.19).

    (setq wkpt (polar cent ang2 dst2))

    Figure 6.19: Finding the workpoint wkpt.

    We assign the corner point location to the variable wkpt. We're still not finished with our little math exercise, however. We still need to
    find the intersection of the cut axis to the circle. Looking at our problem solving sketch, we can see that yet another triangle can be
    used to solve our problem. We know that the intersection lies along the cut axis. We can describe a triangle whose corner is defined by
    the intersection of the circle and the cut axis (see figure 6.20).


    Figure 6.20: The triangle describing one intersection point.

    We also already know two of the sides of this new triangle. One is the radius of the circle stored as the variable rad1. The other is the
    side of the triangle we used earlier stored as the variable dst2. The most direct way to find the intersection is to apply the Pythagorean

    Theorem shown in figure 6.21.
    Figure 6.21: The Pythagorean Theorem

    Again we must apply algebra to derive a formula to suite our needs. The formula:
    c
    2
    = a
    2
    - b
    2
    becomes the expression:

    (setq cord (sqrt(-(* rad1 rad1)(* dst2 dst2))))

    We assign the distance value gotten from the Pythagorean Theorem to the variable cord. Using the Polar function, we can now find one

    intersection point between the circle and the cut axis:


    (setq cpt2 (polar wkpt (angle lpt2 lpt1) cord))
    In this expression, we find one intersection by applying the angle described by lpt1 and lpt2 and the distance described by cord to the
    polar functions (see figure 6.22).
    Figure 6.22: Finding the location of an intersection point.
    Since the two intersection points are symmetric about point wkpt, the second intersection point is found by reversing the direction of
    the angle in previous expression:
    (setq cpt3 (polar wkpt (angle lpt1 lpt2) cord))
    Finally, we can get AutoCAD to do the actual work of cutting the circle:
    (command "erase" cpt1 ""
                    "arc" "c" cent cpt2 cpt3
                    "arc" "c" cent cpt3 cpt2
             )
       )
     
    Actually, we don't really cut the circle. Instead, the circle is erased entirely and replaced with two arcs (see figure 6.23).
    Figure 6.23: Drawing the new circle.


    Functions Useful in Geometric Transformations

    The majority of your graphic problems can be solved with the basic trigonometric functons used in the Cutcr program. But AutoLISP
    provides the tools to solve even th emost arcane trigonometric problems. This section shows the functions you are most likely to use in
    situations that require geometric manipulations.

    Trans

    Trans translates a coordinate or displacement from one user coordinate system to another. The first argument is a point of reference.
    The second argument is a code indicating which coordinate system the point is expressed in. The third argument is a code indicating
    which coordinate system the point is to be translated to. An optional fourth True/nil argument can be included. If this fourth argument
    evaluates to True or non-nil, then the first argument will be treated as a displacement rather than a point value. The following are the
    codes for the second and third arguments.
    Code Coordinate System
    0 World Coordinate System
    1 Current User Coordinate System
    2
    Coordinate system of the current view
    plane
    Trans returns a coordinate or displacement list.
    The syntax for Trans is
    (trans [coordinage_list] [UCS_code] [optionalT/nil] )
    Atan
    Atan returns the arctangent in radians of its first argument. If the argument is negative, then the value returned will be
    negative. If two arguments are supplied, then Atan returns a the arctangent of the first argument divided by the second
    argument.
    The syntax for Atan is
    (atan [number] [optional_2nd_number])
    Inters
    Inters returns a coordinate list of the intersection of two vectors. The first two arguments to inters are the endpoints of one
    vector while the third and fourth arguments define the other vector. If an optional fifth agrument is present and evaluates to
    nil, then Inters will attempt to locate an intersection point of the two vectors regardless of whether the intersection falls
    between the specified points or not.
    The syntax for Inters is
    (inters [point point point point] [optional_T/nil])
    Sin
    Sine returns the sine of an angle as a real number. The angle must be expressed in radians.


    The syntax for Sine is
    (sin [angle])
    Cos
    Cos returns the Cosine of an angle as a real number. The angle must be expressed in radians.
    The syntax for Cos is
    (cos [angle])

    Next -> Conclusion