User Tools

Site Tools


2d_graphics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
2d_graphics [2012/08/01 00:19] javapimp2d_graphics [2023/08/18 18:15] (current) – external edit 127.0.0.1
Line 22: Line 22:
  
 ===== Perpendicular Lines ===== ===== Perpendicular Lines =====
-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`+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. Perpendicular lines will intersect at a single point. The point of intersection is where the `x` and `y` values satisfy both equations.
Line 31: Line 31:
 Intersection: `(2, 3)` Intersection: `(2, 3)`
  
-\begin{graphwidth=400; height=300; xmin=-8.3; xmax=8.3; xscl=1; plot(x-2); plot(2x-1) \end{graph}+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*2); enda``graph 
 +<html> 
 +<embed class="ASCIIsvg" 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); '/> 
 +</html>
  
 We can find the slope of the second line by taking the negative reciprocal of the slop of the first: We can find the slope of the second line by taking the negative reciprocal of the slop of the first:
Line 37: Line 40:
  
 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: 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 amath
 y = mx + b\\ y = mx + b\\
Line 46: Line 50:
 So, the equation of the perpendicular line is: So, the equation of the perpendicular line is:
 `y = -2x + 7` `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);'/>
 +
  
 ===== Intersection of two lines ===== ===== Intersection of two lines =====
-Two lines intersect when the point `(x, y)` satisfies both equations. To determine the point of intersections of two lines:+Two lines intersect when the point `(x, y)` satisfies both equations. To determine the point of intersection of two lines:
  
-amath +`y_1 = 1/2 x_1 + 2`\\ 
-y_1 = 1/2 x_1 + 2\\ +`y_2 = -2x_2 + 7`
-y_2 = -2x_2 + 7 +
-endamath+
  
 Given that `y_1 = y_2` we can write: Given that `y_1 = y_2` we can write:
Line 62: Line 68:
  
 amath amath
-1/2 x + 2 = -2x + 7\\+1/2 x + 2 = -2x + 7 
 + 
 +Now solve for x: 
 1/2 x + 2x + 2 = 7\\ 1/2 x + 2x + 2 = 7\\
 5/2 x + 2 = 7\\ 5/2 x + 2 = 7\\
Line 80: Line 89:
  
 The point of intersection of the two lines is `(2, 3)` The point of intersection of the two lines is `(2, 3)`
 +
 +===== Find point on a line =====
 +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`
  
 ===== Pythagorean theorem ===== ===== Pythagorean theorem =====
2d_graphics.1343780375.txt.gz · Last modified: 2023/08/18 18:15 (external edit)