library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(gifski)
HW Outline
- Part 1: Draw Initials ‘Y’ and ‘Q’
- Creation of ‘Y’
- Creation of ‘Q’
- Part 2: Transformation
- Application of Transformations to ‘Y’ and ‘Q’
Part 1 Draw Initials Y Q
# Diagonal line 1 (left branch of Y)
x_1_y <- seq(-3, -2, length.out = 500)
y_1_y <- seq(2, 0, length.out = 500)
# Diagonal line 2 (right branch of Y)
x_2_y <- seq(-1, -2, length.out = 500)
y_2_y <- seq(2, 0, length.out = 500)
# Vertical line (stem of Y)
x_3_y <- rep(-2, 500)
y_3_y <- seq(0, -2, length.out = 500)
# Combine x and y coordinates for Y
x_y <- c(x_1_y, x_2_y, x_3_y)
y_y <- c(y_1_y, y_2_y, y_3_y)
plot(y_y~x_y, xlim=c(-3,4),ylim=c(-3,3))

# Circle for Q
r = 1 # Radius
h = 2 # x-coordinate of center
k = 0 # y-coordinate of center
theta <- seq(0, 2 * pi, length.out = 1000)
x_q_circle <- h + r * cos(theta)
y_q_circle <- k + r * sin(theta)
# Plot the circle
plot(x_q_circle, y_q_circle, type = "l", xlim = c(-3, 4), ylim = c(-3, 3), aspect = 1, lwd = 6)
## Warning in plot.window(...): "aspect" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "aspect" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "aspect" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "aspect" is not a
## graphical parameter
## Warning in box(...): "aspect" is not a graphical parameter
## Warning in title(...): "aspect" is not a graphical parameter
# Tail
x1 <- 2
y1 <- -0.5
x2 <- 2.5
y2 <- -1.5
m <- (y2 - y1) / (x2 - x1)
b <- y1 - m * x1
x_2_q <- seq(2, 2.5, length.out = 100)
y_2_q <- m * x_2_q + b
# Add the tail to the plot
lines(x_2_q, y_2_q, lwd = 6)

# Combine x and y coordinates for Y and Q
x <- c(x_y, x_q_circle, x_2_q)
y <- c(y_y, y_q_circle, y_2_q)
yq <- rbind(x, y)
plot(y~x, xlim=c(-3,4),ylim=c(-3,3))
