Equation of a straight line in 3 coordinates. Equation of a straight line passing through two points

The canonical equations of a straight line in space are equations that define a straight line passing through a given point collinearly to a direction vector.

Let a point and a direction vector be given. An arbitrary point lies on a line l only if the vectors and are collinear, i.e., they satisfy the condition:

.

The above equations are the canonical equations of the line.

Numbers m , n and p are projections of the direction vector onto the coordinate axes. Since the vector is non-zero, then all numbers m , n and p cannot be zero at the same time. But one or two of them may be zero. In analytical geometry, for example, the following notation is allowed:

,

which means that the projections of the vector on the axes Oy and Oz are equal to zero. Therefore, both the vector and the straight line given by the canonical equations are perpendicular to the axes Oy and Oz, i.e. planes yOz .

Example 1 Compose equations of a straight line in space perpendicular to a plane and passing through the point of intersection of this plane with the axis Oz .

Solution. Find the point of intersection of the given plane with the axis Oz. Since any point on the axis Oz, has coordinates , then, assuming in the given equation of the plane x=y= 0 , we get 4 z- 8 = 0 or z= 2 . Therefore, the point of intersection of the given plane with the axis Oz has coordinates (0; 0; 2) . Since the desired line is perpendicular to the plane, it is parallel to its normal vector. Therefore, the normal vector can serve as the directing vector of the straight line given plane.

Now we write the desired equations of the straight line passing through the point A= (0; 0; 2) in the direction of the vector :

Equations of a straight line passing through two given points

A straight line can be defined by two points lying on it and In this case, the directing vector of the straight line can be the vector . Then the canonical equations of the line take the form

.

The above equations define a straight line passing through two given points.

Example 2 Write the equation of a straight line in space passing through the points and .

Solution. We write the desired equations of the straight line in the form given above in the theoretical reference:

.

Since , then the desired line is perpendicular to the axis Oy .

Straight as a line of intersection of planes

A straight line in space can be defined as a line of intersection of two non-parallel planes and, i.e., as a set of points that satisfy a system of two linear equations

The equations of the system are also called the general equations of a straight line in space.

Example 3 Compose canonical equations of a straight line in the space given by general equations

Solution. To write the canonical equations of a straight line or, what is the same, the equation of a straight line passing through two given points, you need to find the coordinates of any two points on the straight line. They can be the points of intersection of a straight line with any two coordinate planes, for example yOz and xOz .

Point of intersection of a line with a plane yOz has an abscissa x= 0 . Therefore, assuming in this system of equations x= 0 , we get a system with two variables:

Her decision y = 2 , z= 6 together with x= 0 defines a point A(0; 2; 6) of the desired line. Assuming then in the given system of equations y= 0 , we get the system

Her decision x = -2 , z= 0 together with y= 0 defines a point B(-2; 0; 0) intersection of a line with a plane xOz .

Now we write the equations of a straight line passing through the points A(0; 2; 6) and B (-2; 0; 0) :

,

or after dividing the denominators by -2:

,

Equation of a line passing through a given point in a given direction. Equation of a straight line passing through two given points. Angle between two lines. Condition of parallelism and perpendicularity of two lines. Determining the point of intersection of two lines

1. Equation of a line passing through a given point A(x 1 , y 1) in a given direction, determined by the slope k,

y - y 1 = k(x - x 1). (1)

This equation defines a pencil of lines passing through a point A(x 1 , y 1), which is called the center of the beam.

2. Equation of a straight line passing through two points: A(x 1 , y 1) and B(x 2 , y 2) is written like this:

The slope of a straight line passing through two given points is determined by the formula

3. Angle between straight lines A and B is the angle by which the first straight line must be rotated A around the point of intersection of these lines counterclockwise until it coincides with the second line B. If two lines are given by slope equations

y = k 1 x + B 1 ,

Let two points be given M(X 1 ,At 1) and N(X 2,y 2). Let's find the equation of the straight line passing through these points.

Since this line passes through the point M, then according to formula (1.13) its equation has the form

AtY 1 = K(X-x 1),

Where K is the unknown slope.

The value of this coefficient is determined from the condition that the desired straight line passes through the point N, which means that its coordinates satisfy equation (1.13)

Y 2 – Y 1 = K(X 2 – X 1),

From here you can find the slope of this line:

,

Or after conversion

(1.14)

Formula (1.14) defines Equation of a line passing through two points M(X 1, Y 1) and N(X 2, Y 2).

In the particular case when the points M(A, 0), N(0, B), BUT ¹ 0, B¹ 0, lie on the coordinate axes, equation (1.14) takes a simpler form

Equation (1.15) called Equation of a straight line in segments, here BUT and B denote segments cut off by a straight line on the axes (Figure 1.6).

Figure 1.6

Example 1.10. Write the equation of a straight line passing through the points M(1, 2) and B(3, –1).

. According to (1.14), the equation of the desired straight line has the form

2(Y – 2) = -3(X – 1).

Transferring all the terms to the left side, we finally obtain the desired equation

3X + 2Y – 7 = 0.

Example 1.11. Write an equation for a line passing through a point M(2, 1) and the point of intersection of the lines X+ Y- 1 = 0, X - y+ 2 = 0.

. We find the coordinates of the point of intersection of the lines by solving these equations together

If we add these equations term by term, we get 2 X+ 1 = 0, whence . Substituting the found value into any equation, we find the value of the ordinate At:

Now let's write the equation of a straight line passing through the points (2, 1) and :

or .

Hence or -5( Y – 1) = X – 2.

Finally, we obtain the equation of the desired straight line in the form X + 5Y – 7 = 0.

Example 1.12. Find the equation of a straight line passing through points M(2.1) and N(2,3).

Using formula (1.14), we obtain the equation

It doesn't make sense because the second denominator is zero. It can be seen from the condition of the problem that the abscissas of both points have the same value. Hence, the required line is parallel to the axis OY and its equation is: x = 2.

Comment . If, when writing the equation of a straight line according to formula (1.14), one of the denominators turns out to be equal to zero, then the desired equation can be obtained by equating the corresponding numerator to zero.

Let's consider other ways of setting a straight line on a plane.

1. Let a non-zero vector be perpendicular to a given line L, and the point M 0(X 0, Y 0) lies on this line (Figure 1.7).

Figure 1.7

Denote M(X, Y) an arbitrary point on the line L. Vectors and Orthogonal. Using the orthogonality conditions for these vectors, we obtain or BUT(XX 0) + B(YY 0) = 0.

We have obtained the equation of a straight line passing through a point M 0 is perpendicular to the vector . This vector is called Normal vector to a straight line L. The resulting equation can be rewritten as

Oh + Wu + FROM= 0, where FROM = –(BUTX 0 + By 0), (1.16),

Where BUT and AT are the coordinates of the normal vector.

We obtain the general equation of a straight line in a parametric form.

2. A line on a plane can be defined as follows: let a non-zero vector be parallel to a given line L and dot M 0(X 0, Y 0) lies on this line. Again, take an arbitrary point M(X, y) on a straight line (Figure 1.8).

Figure 1.8

Vectors and collinear.

Let us write down the condition of collinearity of these vectors: , where T is an arbitrary number, called a parameter. Let's write this equality in coordinates:

These equations are called Parametric equations Straight. Let us exclude from these equations the parameter T:

These equations can be written in the form

. (1.18)

The resulting equation is called The canonical equation of a straight line. Vector call Direction vector straight .

Comment . It is easy to see that if is the normal vector to the line L, then its direction vector can be the vector , since , i.e. .

Example 1.13. Write the equation of a straight line passing through a point M 0(1, 1) parallel to line 3 X + 2At– 8 = 0.

Solution . The vector is the normal vector to the given and desired lines. Let's use the equation of a straight line passing through a point M 0 with a given normal vector 3( X –1) + 2(At– 1) = 0 or 3 X + 2y- 5 \u003d 0. We got the equation of the desired straight line.

This article continues the topic of the equation of a straight line on a plane: consider such a type of equation as the general equation of a straight line. Let's define a theorem and give its proof; Let's figure out what an incomplete general equation of a straight line is and how to make transitions from a general equation to other types of equations of a straight line. We will consolidate the whole theory with illustrations and solving practical problems.

Yandex.RTB R-A-339285-1

Let a rectangular coordinate system O x y be given on the plane.

Theorem 1

Any equation of the first degree, having the form A x + B y + C \u003d 0, where A, B, C are some real numbers (A and B are not equal to zero at the same time) defines a straight line in a rectangular coordinate system on the plane. In turn, any line in a rectangular coordinate system on the plane is determined by an equation that has the form A x + B y + C = 0 for a certain set of values ​​A, B, C.

Proof

This theorem consists of two points, we will prove each of them.

  1. Let us prove that the equation A x + B y + C = 0 defines a line on the plane.

Let there be some point M 0 (x 0 , y 0) whose coordinates correspond to the equation A x + B y + C = 0 . Thus: A x 0 + B y 0 + C = 0 . Subtract from the left and right sides of the equations A x + B y + C \u003d 0 the left and right sides of the equation A x 0 + B y 0 + C \u003d 0, we get a new equation that looks like A (x - x 0) + B (y - y 0) = 0 . It is equivalent to A x + B y + C = 0 .

The resulting equation A (x - x 0) + B (y - y 0) = 0 is a necessary and sufficient condition for the perpendicularity of the vectors n → = (A, B) and M 0 M → = (x - x 0, y - y 0 ) . Thus, the set of points M (x, y) defines in a rectangular coordinate system a straight line perpendicular to the direction of the vector n → = (A, B) . We can assume that this is not so, but then the vectors n → = (A, B) and M 0 M → = (x - x 0, y - y 0) would not be perpendicular, and the equality A (x - x 0 ) + B (y - y 0) = 0 would not be true.

Therefore, the equation A (x - x 0) + B (y - y 0) \u003d 0 defines a certain line in a rectangular coordinate system on the plane, and therefore the equivalent equation A x + B y + C \u003d 0 defines the same line. Thus we have proved the first part of the theorem.

  1. Let us prove that any straight line in a rectangular coordinate system on a plane can be given by an equation of the first degree A x + B y + C = 0 .

Let's set a straight line a in a rectangular coordinate system on the plane; point M 0 (x 0 , y 0) through which this line passes, as well as the normal vector of this line n → = (A , B) .

Let there also exist some point M (x , y) - a floating point of the line. In this case, the vectors n → = (A , B) and M 0 M → = (x - x 0 , y - y 0) are perpendicular to each other, and their scalar product is zero:

n → , M 0 M → = A (x - x 0) + B (y - y 0) = 0

Let's rewrite the equation A x + B y - A x 0 - B y 0 = 0 , define C: C = - A x 0 - B y 0 and finally get the equation A x + B y + C = 0 .

So, we have proved the second part of the theorem, and we have proved the whole theorem as a whole.

Definition 1

An equation that looks like A x + B y + C = 0 - this is general equation of a straight line on a plane in a rectangular coordinate systemO x y .

Based on the proved theorem, we can conclude that a straight line given on a plane in a fixed rectangular coordinate system and its general equation are inextricably linked. In other words, the original line corresponds to its general equation; the general equation of a straight line corresponds to a given straight line.

It also follows from the proof of the theorem that the coefficients A and B for the variables x and y are the coordinates of the normal vector of the straight line, which is given by the general equation of the straight line A x + B y + C = 0 .

Consider a specific example of the general equation of a straight line.

Let the equation 2 x + 3 y - 2 = 0 be given, which corresponds to a straight line in a given rectangular coordinate system. The normal vector of this line is the vector n → = (2 , 3) ​​. Draw a given straight line in the drawing.

The following can also be argued: the straight line that we see in the drawing is determined by the general equation 2 x + 3 y - 2 = 0, since the coordinates of all points of a given straight line correspond to this equation.

We can get the equation λ · A x + λ · B y + λ · C = 0 by multiplying both sides of the general straight line equation by a non-zero number λ. The resulting equation is equivalent to the original general equation, therefore, it will describe the same line in the plane.

Definition 2

Complete general equation of a straight line- such a general equation of the line A x + B y + C \u003d 0, in which the numbers A, B, C are non-zero. Otherwise, the equation is incomplete.

Let us analyze all variations of the incomplete general equation of the straight line.

  1. When A \u003d 0, B ≠ 0, C ≠ 0, the general equation becomes B y + C \u003d 0. Such an incomplete general equation defines a straight line in the rectangular coordinate system O x y that is parallel to the O x axis, since for any real value of x, the variable y will take on the value - C B . In other words, the general equation of the line A x + B y + C \u003d 0, when A \u003d 0, B ≠ 0, defines the locus of points (x, y) whose coordinates are equal to the same number - C B .
  2. If A \u003d 0, B ≠ 0, C \u003d 0, the general equation becomes y \u003d 0. Such an incomplete equation defines the x-axis O x .
  3. When A ≠ 0, B \u003d 0, C ≠ 0, we get an incomplete general equation A x + C \u003d 0, defining a straight line parallel to the y-axis.
  4. Let A ≠ 0, B \u003d 0, C \u003d 0, then the incomplete general equation will take the form x \u003d 0, and this is the equation of the coordinate line O y.
  5. Finally, when A ≠ 0, B ≠ 0, C \u003d 0, the incomplete general equation takes the form A x + B y \u003d 0. And this equation describes a straight line that passes through the origin. Indeed, the pair of numbers (0 , 0) corresponds to the equality A x + B y = 0 , since A · 0 + B · 0 = 0 .

Let us graphically illustrate all the above types of the incomplete general equation of a straight line.

Example 1

It is known that the given straight line is parallel to the y-axis and passes through the point 2 7 , - 11 . It is necessary to write down the general equation of a given straight line.

Solution

A straight line parallel to the y-axis is given by an equation of the form A x + C \u003d 0, in which A ≠ 0. The condition also specifies the coordinates of the point through which the line passes, and the coordinates of this point correspond to the conditions of the incomplete general equation A x + C = 0 , i.e. equality is correct:

A 2 7 + C = 0

It is possible to determine C from it by giving A some non-zero value, for example, A = 7 . In this case, we get: 7 2 7 + C \u003d 0 ⇔ C \u003d - 2. We know both coefficients A and C, substitute them into the equation A x + C = 0 and get the required equation of the line: 7 x - 2 = 0

Answer: 7 x - 2 = 0

Example 2

The drawing shows a straight line, it is necessary to write down its equation.

Solution

The given drawing allows us to easily take the initial data for solving the problem. We see in the drawing that the given line is parallel to the O x axis and passes through the point (0 , 3) ​​.

The straight line, which is parallel to the abscissa, is determined by the incomplete general equation B y + С = 0. Find the values ​​of B and C . The coordinates of the point (0, 3), since a given straight line passes through it, will satisfy the equation of the straight line B y + С = 0, then the equality is valid: В · 3 + С = 0. Let's set B to some value other than zero. Let's say B \u003d 1, in this case, from the equality B · 3 + C \u003d 0 we can find C: C \u003d - 3. Using the known values ​​of B and C, we obtain the required equation of the straight line: y - 3 = 0.

Answer: y - 3 = 0 .

General equation of a straight line passing through a given point of the plane

Let the given line pass through the point M 0 (x 0, y 0), then its coordinates correspond to the general equation of the line, i.e. the equality is true: A x 0 + B y 0 + C = 0 . Subtract the left and right sides of this equation from the left and right sides of the general complete equation of the straight line. We get: A (x - x 0) + B (y - y 0) + C \u003d 0, this equation is equivalent to the original general one, passes through the point M 0 (x 0, y 0) and has a normal vector n → \u003d (A, B) .

The result that we have obtained makes it possible to write down the general equation of a straight line with the known coordinates of the normal vector of the straight line and the coordinates of a certain point of this straight line.

Example 3

Given a point M 0 (- 3, 4) through which the line passes, and the normal vector of this line n → = (1 , - 2) . It is necessary to write down the equation of a given straight line.

Solution

The initial conditions allow us to obtain the necessary data for compiling the equation: A \u003d 1, B \u003d - 2, x 0 \u003d - 3, y 0 \u003d 4. Then:

A (x - x 0) + B (y - y 0) = 0 ⇔ 1 (x - (- 3)) - 2 y (y - 4) = 0 ⇔ ⇔ x - 2 y + 22 = 0

The problem could have been solved differently. The general equation of a straight line has the form A x + B y + C = 0 . The given normal vector allows you to get the values ​​of the coefficients A and B , then:

A x + B y + C = 0 ⇔ 1 x - 2 y + C = 0 ⇔ x - 2 y + C = 0

Now let's find the value of C, using the point M 0 (- 3, 4) given by the condition of the problem, through which the line passes. The coordinates of this point correspond to the equation x - 2 · y + C = 0 , i.e. - 3 - 2 4 + C \u003d 0. Hence C = 11. The required straight line equation takes the form: x - 2 · y + 11 = 0 .

Answer: x - 2 y + 11 = 0 .

Example 4

Given a line 2 3 x - y - 1 2 = 0 and a point M 0 lying on this line. Only the abscissa of this point is known, and it is equal to - 3. It is necessary to determine the ordinate of the given point.

Solution

Let's set the designation of the coordinates of the point M 0 as x 0 and y 0 . The initial data indicates that x 0 \u003d - 3. Since the point belongs to a given line, then its coordinates correspond to the general equation of this line. Then the following equality will be true:

2 3 x 0 - y 0 - 1 2 = 0

Define y 0: 2 3 (- 3) - y 0 - 1 2 = 0 ⇔ - 5 2 - y 0 = 0 ⇔ y 0 = - 5 2

Answer: - 5 2

Transition from the general equation of a straight line to other types of equations of a straight line and vice versa

As we know, there are several types of the equation of the same straight line in the plane. The choice of the type of equation depends on the conditions of the problem; it is possible to choose the one that is more convenient for its solution. This is where the skill of converting an equation of one kind into an equation of another kind comes in very handy.

First, consider the transition from the general equation of the form A x + B y + C = 0 to the canonical equation x - x 1 a x = y - y 1 a y .

If A ≠ 0, then we transfer the term B y to the right side of the general equation. On the left side, we take A out of brackets. As a result, we get: A x + C A = - B y .

This equality can be written as a proportion: x + C A - B = y A .

If B ≠ 0, we leave only the term A x on the left side of the general equation, we transfer the others to the right side, we get: A x \u003d - B y - C. We take out - B out of brackets, then: A x \u003d - B y + C B.

Let's rewrite the equality as a proportion: x - B = y + C B A .

Of course, there is no need to memorize the resulting formulas. It is enough to know the algorithm of actions during the transition from the general equation to the canonical one.

Example 5

The general equation of the line 3 y - 4 = 0 is given. It needs to be converted to a canonical equation.

Solution

We write the original equation as 3 y - 4 = 0 . Next, we act according to the algorithm: the term 0 x remains on the left side; and on the right side we take out - 3 out of brackets; we get: 0 x = - 3 y - 4 3 .

Let's write the resulting equality as a proportion: x - 3 = y - 4 3 0 . Thus, we have obtained an equation of the canonical form.

Answer: x - 3 = y - 4 3 0.

To transform the general equation of a straight line into parametric ones, first, the transition to the canonical form is carried out, and then the transition from the canonical equation of the straight line to parametric equations.

Example 6

The straight line is given by the equation 2 x - 5 y - 1 = 0 . Write down the parametric equations of this line.

Solution

Let's make the transition from the general equation to the canonical one:

2 x - 5 y - 1 = 0 ⇔ 2 x = 5 y + 1 ⇔ 2 x = 5 y + 1 5 ⇔ x 5 = y + 1 5 2

Now let's take both parts of the resulting canonical equation equal to λ, then:

x 5 = λ y + 1 5 2 = λ ⇔ x = 5 λ y = - 1 5 + 2 λ , λ ∈ R

Answer:x = 5 λ y = - 1 5 + 2 λ , λ ∈ R

The general equation can be converted to a straight line equation with a slope y = k x + b, but only when B ≠ 0. For the transition on the left side, we leave the term B y , the rest are transferred to the right. We get: B y = - A x - C . Let's divide both parts of the resulting equality by B , which is different from zero: y = - A B x - C B .

Example 7

The general equation of a straight line is given: 2 x + 7 y = 0 . You need to convert that equation to a slope equation.

Solution

Let's perform the necessary actions according to the algorithm:

2 x + 7 y = 0 ⇔ 7 y - 2 x ⇔ y = - 2 7 x

Answer: y = - 2 7 x .

From the general equation of a straight line, it is enough to simply obtain an equation in segments of the form x a + y b \u003d 1. To make such a transition, we transfer the number C to the right side of the equality, divide both parts of the resulting equality by - С and, finally, transfer the coefficients for the variables x and y to the denominators:

A x + B y + C = 0 ⇔ A x + B y = - C ⇔ ⇔ A - C x + B - C y = 1 ⇔ x - C A + y - C B = 1

Example 8

It is necessary to convert the general equation of the straight line x - 7 y + 1 2 = 0 into the equation of a straight line in segments.

Solution

Let's move 1 2 to the right side: x - 7 y + 1 2 = 0 ⇔ x - 7 y = - 1 2 .

Divide by -1/2 both sides of the equation: x - 7 y = - 1 2 ⇔ 1 - 1 2 x - 7 - 1 2 y = 1 .

Answer: x - 1 2 + y 1 14 = 1 .

In general, the reverse transition is also easy: from other types of equations to the general one.

The equation of a straight line in segments and the equation with a slope can be easily converted into a general one by simply collecting all the terms on the left side of the equation:

x a + y b ⇔ 1 a x + 1 b y - 1 = 0 ⇔ A x + B y + C = 0 y = k x + b ⇔ y - k x - b = 0 ⇔ A x + B y + C = 0

The canonical equation is converted to the general one according to the following scheme:

x - x 1 a x = y - y 1 a y ⇔ a y (x - x 1) = a x (y - y 1) ⇔ ⇔ a y x - a x y - a y x 1 + a x y 1 = 0 ⇔ A x + B y + C = 0

To pass from the parametric, first the transition to the canonical is carried out, and then to the general one:

x = x 1 + a x λ y = y 1 + a y λ ⇔ x - x 1 a x = y - y 1 a y ⇔ A x + B y + C = 0

Example 9

The parametric equations of the straight line x = - 1 + 2 · λ y = 4 are given. It is necessary to write down the general equation of this line.

Solution

Let's make the transition from parametric equations to canonical:

x = - 1 + 2 λ y = 4 ⇔ x = - 1 + 2 λ y = 4 + 0 λ ⇔ λ = x + 1 2 λ = y - 4 0 ⇔ x + 1 2 = y - 4 0

Let's move from canonical to general:

x + 1 2 = y - 4 0 ⇔ 0 (x + 1) = 2 (y - 4) ⇔ y - 4 = 0

Answer: y - 4 = 0

Example 10

The equation of a straight line in segments x 3 + y 1 2 = 1 is given. It is necessary to carry out the transition to the general form of the equation.

Solution:

Let's just rewrite the equation in the required form:

x 3 + y 1 2 = 1 ⇔ 1 3 x + 2 y - 1 = 0

Answer: 1 3 x + 2 y - 1 = 0 .

Drawing up a general equation of a straight line

Above, we said that the general equation can be written with known coordinates of the normal vector and the coordinates of the point through which the line passes. Such a straight line is defined by the equation A (x - x 0) + B (y - y 0) = 0 . In the same place we analyzed the corresponding example.

Now let's look at more complex examples in which, first, it is necessary to determine the coordinates of the normal vector.

Example 11

Given a line parallel to the line 2 x - 3 y + 3 3 = 0 . Also known is the point M 0 (4 , 1) through which the given line passes. It is necessary to write down the equation of a given straight line.

Solution

The initial conditions tell us that the lines are parallel, then, as the normal vector of the line whose equation needs to be written, we take the directing vector of the line n → = (2, - 3) : 2 x - 3 y + 3 3 = 0. Now we know all the necessary data to compose the general equation of a straight line:

A (x - x 0) + B (y - y 0) = 0 ⇔ 2 (x - 4) - 3 (y - 1) = 0 ⇔ 2 x - 3 y - 5 = 0

Answer: 2 x - 3 y - 5 = 0 .

Example 12

The given line passes through the origin perpendicular to the line x - 2 3 = y + 4 5 . It is necessary to write the general equation of a given straight line.

Solution

The normal vector of the given line will be the directing vector of the line x - 2 3 = y + 4 5 .

Then n → = (3 , 5) . The straight line passes through the origin, i.e. through the point O (0, 0) . Let's compose the general equation of a given straight line:

A (x - x 0) + B (y - y 0) = 0 ⇔ 3 (x - 0) + 5 (y - 0) = 0 ⇔ 3 x + 5 y = 0

Answer: 3 x + 5 y = 0 .

If you notice a mistake in the text, please highlight it and press Ctrl+Enter

Lesson from the series "Geometric Algorithms"

Hello dear reader!

Today we will start learning algorithms related to geometry. The fact is that there are a lot of Olympiad problems in computer science related to computational geometry, and the solution of such problems often causes difficulties.

In a few lessons, we will consider a number of elementary subproblems on which the solution of most problems of computational geometry is based.

In this lesson, we will write a program for finding the equation of a straight line passing through the given two dots. To solve geometric problems, we need some knowledge of computational geometry. We will devote part of the lesson to getting to know them.

Information from computational geometry

Computational geometry is a branch of computer science that studies algorithms for solving geometric problems.

The initial data for such problems can be a set of points on the plane, a set of segments, a polygon (given, for example, by a list of its vertices in clockwise order), etc.

The result can be either an answer to some question (such as does a point belong to a segment, do two segments intersect, ...), or some geometric object (for example, the smallest convex polygon connecting given points, the area of ​​a polygon, etc.) .

We will consider problems of computational geometry only on the plane and only in the Cartesian coordinate system.

Vectors and coordinates

To apply the methods of computational geometry, it is necessary to translate geometric images into the language of numbers. We assume that a Cartesian coordinate system is given on the plane, in which the direction of rotation counterclockwise is called positive.

Now geometric objects receive an analytical expression. So, to set a point, it is enough to specify its coordinates: a pair of numbers (x; y). A segment can be specified by specifying the coordinates of its ends, a straight line can be specified by specifying the coordinates of a pair of its points.

But the main tool for solving problems will be vectors. Let me remind you, therefore, of some information about them.

Line segment AB, which has a point BUT considered the beginning (point of application), and the point AT- the end is called a vector AB and denoted by either , or a bold lowercase letter, for example a .

To denote the length of a vector (that is, the length of the corresponding segment), we will use the module symbol (for example, ).

An arbitrary vector will have coordinates equal to the difference between the corresponding coordinates of its end and beginning:

,

dots here A and B have coordinates respectively.

For calculations, we will use the concept oriented angle, that is, an angle that takes into account the relative position of the vectors.

Oriented angle between vectors a and b positive if the rotation is away from the vector a to the vector b is done in the positive direction (counterclockwise) and negative in the other case. See fig.1a, fig.1b. It is also said that a pair of vectors a and b positively (negatively) oriented.

Thus, the value of the oriented angle depends on the order of enumeration of the vectors and can take values ​​in the interval .

Many computational geometry problems use the concept of vector (skew or pseudoscalar) products of vectors.

The vector product of vectors a and b is the product of the lengths of these vectors and the sine of the angle between them:

.

Vector product of vectors in coordinates:

The expression on the right is a second-order determinant:

Unlike the definition given in analytic geometry, this is a scalar.

The sign of the cross product determines the position of the vectors relative to each other:

a and b positively oriented.

If the value is , then the pair of vectors a and b negatively oriented.

The cross product of nonzero vectors is zero if and only if they are collinear ( ). This means that they lie on the same line or on parallel lines.

Let's consider some simple tasks necessary for solving more complex ones.

Let's define the equation of a straight line by the coordinates of two points.

The equation of a straight line passing through two different points given by their coordinates.

Let two non-coinciding points are given on the line: with coordinates (x1;y1) and with coordinates (x2; y2). Accordingly, the vector with the beginning at the point and the end at the point has coordinates (x2-x1, y2-y1). If P(x, y) is an arbitrary point on our line, then the coordinates of the vector are (x-x1, y - y1).

With the help of the cross product, the condition for the collinearity of the vectors and can be written as follows:

Those. (x-x1)(y2-y1)-(y-y1)(x2-x1)=0

(y2-y1)x + (x1-x2)y + x1(y1-y2) + y1(x2-x1) = 0

We rewrite the last equation as follows:

ax + by + c = 0, (1)

c = x1(y1-y2) + y1(x2-x1)

So, the straight line can be given by an equation of the form (1).

Task 1. The coordinates of two points are given. Find its representation in the form ax + by + c = 0.

In this lesson, we got acquainted with some information from computational geometry. We solved the problem of finding the equation of the line by the coordinates of two points.

In the next lesson, we will write a program to find the point of intersection of two lines given by our equations.