|
38 | 38 | <td><h3>bezierTangent</h3></td> |
39 | 39 | </tr> |
40 | 40 |
|
| 41 | + <tr class=""><th scope="row">Examples</th><td> |
| 42 | + <div class="example"> <pre># bezierTangent 2 https://processing.org/reference/bezierTangent_.html |
| 43 | + |
| 44 | +noFill() |
| 45 | +bezier(85, 20, 10, 10, 90, 90, 15, 80) |
| 46 | +stroke(255, 102, 0) |
| 47 | +steps <- 16 |
| 48 | +for (i in 0:steps) { |
| 49 | + t <- i/steps |
| 50 | + x <- bezierPoint(85, 10, 90, 15, t) |
| 51 | + y <- bezierPoint(20, 10, 90, 80, t) |
| 52 | + tx <- bezierTangent(85, 10, 90, 15, t) |
| 53 | + ty <- bezierTangent(20, 10, 90, 80, t) |
| 54 | + a <- atan2(ty, tx) |
| 55 | + a <- a - HALF_PI |
| 56 | + line(x, y, cos(a) * 8 + x, sin(a) * 8 + y) |
| 57 | +} |
| 58 | +</pre> |
| 59 | + </div> |
| 60 | + <div class="example"> <pre># bezierTangent 1 https://processing.org/reference/bezierTangent_.html |
| 61 | + |
| 62 | +noFill() |
| 63 | +bezier(85, 20, 10, 10, 90, 90, 15, 80) |
| 64 | +steps <- 6 |
| 65 | +fill(255) |
| 66 | +for (i in 0:steps) { |
| 67 | + t <- i/steps |
| 68 | + # Get the location of the point |
| 69 | + x <- bezierPoint(85, 10, 90, 15, t) |
| 70 | + y <- bezierPoint(20, 10, 90, 80, t) |
| 71 | + # Get the tangent points |
| 72 | + tx <- bezierTangent(85, 10, 90, 15, t) |
| 73 | + ty <- bezierTangent(20, 10, 90, 80, t) |
| 74 | + # Calculate an angle from the tangent points |
| 75 | + a <- atan2(ty, tx) |
| 76 | + a = a + PI |
| 77 | + stroke(255, 102, 0) |
| 78 | + line(x, y, cos(a) * 30 + x, sin(a) * 30 + y) |
| 79 | + # The following line of code makes a line inverse of the above line line(x, y, |
| 80 | + # cos(a)*-30 + x, sin(a)*-30 + y) |
| 81 | + stroke(0) |
| 82 | + ellipse(x, y, 5, 5) |
| 83 | +} |
| 84 | +</pre> |
| 85 | + </div> |
| 86 | + </tr> |
41 | 87 |
|
42 | 88 | <tr class=""> |
43 | 89 | <th scope="row">Description</th> |
|
0 commit comments