2d_graphics

`y = mx + b`

`m = (Delta y)/(Delta x) = (y_2 - y_1)/(x_2 - x_1)`

*Y-intercept*- where the line intersects with the line defined by the Y-axis- The line intersects the Y-axis when `x` is `0`.

amath
y = mx + b

y = m(0) + b

y = 0 + b

y = b

endamath

`y = m(x - x_1) + y_1`

The slope of a line perpendicular to a given line is the *negative reciprocal* of the slope of the given line. For example, given the line: `y = mx + b`, the slope of a line perpendicular is: `m_1 = -1/m`

Perpendicular lines will intersect at a single point. The point of intersection is where the `x` and `y` values satisfy both equations.

Given a point on the line, find the equation of the line perpendicular to that line intersecting at that point:

Line: `y = 1/2 x + 2`

Intersection: `(2, 3)`

a``graph width=320; height=220; xmin=-8.3; xmax=8.3; ymin=-3.3; ymax=8.3; xscl=1; yscl=1; plot(1/2*x + 2); enda``graph

We can find the slope of the second line by taking the negative reciprocal of the slop of the first: `m_1 = -2/1 = -2`

Next we need to find the Y-intercept. In this case, we know the slope of the line and a point that satisfies the line. All we need to do is plug in those values and solve for b:

amath
y = mx + b

3 = -2 * 2 + b

3 = -4 + b

b = 7

endamath

So, the equation of the perpendicular line is: `y = -2x + 7`

<embed class="ASCIIsvg" src="http://www.fourthwoods.com/js/d.svg" wmode="transparent" script=' width=320; height=220; xmin=-8.3; xmax=8.3; ymin=-3.3; ymax=8.3; xscl=1; yscl=1; plot(1/2*x + 2); plot(-2x + 7);'/>

Two lines intersect when the point `(x, y)` satisfies both equations. To determine the point of intersection of two lines:

`y_1 = 1/2 x_1 + 2`

`y_2 = -2x_2 + 7`

Given that `y_1 = y_2` we can write:

`1/2 x_1 + 2 = -2x_2 + 7`

Since `x_1 = x_2` we can write:

amath 1/2 x + 2 = -2x + 7

Now solve for x:

1/2 x + 2x + 2 = 7

5/2 x + 2 = 7

5/2 x = 5

5x = 10

x = 2
endamath

Now that we have an `x` value we can use one of the equations to find the `y`.

amath
y = 1/2 x + 2

y = 1/2 * 2 + 2

y = 1 + 2

y = 3
endamath

The point of intersection of the two lines is `(2, 3)`

Given a point on a line `(x, y)` a slope `m` and a distance `d` along the line from the given point, what is the `(x_1, y_1)` of the new point?

`c = cos(theta) = 1/sqrt(1 + m^2)`

`s = sin(theta) = m/sqrt(1 + m^2)`

`x_1 = x + d * c`

`y_1 = y + d * s`

`c^2 = a^2 + b^2` or `c = sqrt(a^2 + b^2)`

2d_graphics.txt · Last modified: 2016/05/15 17:27 by javapimp