Ejercicio 1 :No equivalentes, no paralelos

## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

## $PQ
## [1] 3 4
## 
## $AB
## [1]  6 -3
## 
## $equivalentes
## [1] FALSE
## 
## $paralelos
## [1] FALSE

Ejercicio 2 : Equivalentes y paralelos

## $PQ
## [1] -4  1
## 
## $AB
## [1] -4  1
## 
## $equivalentes
## [1] TRUE
## 
## $paralelos
## [1] TRUE

Ejercicio 3 : No equivalentes, no paralelos

P <- c(1,-1,5); Q <- c(-2,3,-4)
A <- c(3,1,1);  B <- c(0,5,10)

PQ <- Q-P
AB <- B-A

scatter3D(x=c(P[1],Q[1],A[1],B[1]),
          y=c(P[2],Q[2],A[2],B[2]),
          z=c(P[3],Q[3],A[3],B[3]),
          colvar=NULL, pch=19, cex=1.5,
          main="Ejercicio 3: vectores en 3D")
arrows3D(x0=c(P[1],A[1]), y0=c(P[2],A[2]), z0=c(P[3],A[3]),
         x1=c(Q[1],B[1]), y1=c(Q[2],B[2]), z1=c(Q[3],B[3]),
         col=c("blue","red"), lwd=2, add=TRUE)

equivalentes <- all(PQ==AB)
paralelos <- all(PQ != 0) && all(AB != 0) &&
             all(PQ/AB == PQ[1]/AB[1])

list(PQ=PQ, AB=AB, equivalentes=equivalentes, paralelos=paralelos)
## $PQ
## [1] -3  4 -9
## 
## $AB
## [1] -3  4  9
## 
## $equivalentes
## [1] FALSE
## 
## $paralelos
## [1] FALSE

Ejercicio 4 : Equivalentes y paralelos

P <- c(2,3,-4); Q <- c(-1,3,5)
A <- c(-2,3,-1); B <- c(-5,3,8)

PQ <- Q-P
AB <- B-A

scatter3D(x=c(P[1],Q[1],A[1],B[1]),
          y=c(P[2],Q[2],A[2],B[2]),
          z=c(P[3],Q[3],A[3],B[3]),
          colvar=NULL, pch=19, cex=1.5,
          main="Ejercicio 4: vectores en 3D")
arrows3D(x0=c(P[1],A[1]), y0=c(P[2],A[2]), z0=c(P[3],A[3]),
         x1=c(Q[1],B[1]), y1=c(Q[2],B[2]), z1=c(Q[3],B[3]),
         col=c("blue","red"), lwd=2, add=TRUE)

equivalentes <- all(PQ==AB)
paralelos <- all(PQ != 0) && all(AB != 0) &&
             all(PQ/AB == PQ[1]/AB[1])

list(PQ=PQ, AB=AB, equivalentes=equivalentes, paralelos=paralelos)
## $PQ
## [1] -3  0  9
## 
## $AB
## [1] -3  0  9
## 
## $equivalentes
## [1] TRUE
## 
## $paralelos
## [1] FALSE

Ejercicio 5 :No paralelos

P=(1,-1), Q=(4,3), A=(-1,5), B=(7,1)

P <- c(1,-1); Q <- c(4,3)
A <- c(-1,5); B <- c(7,1)

PQ <- Q-P
AB <- B-A

df <- data.frame(x=c(P[1],A[1]), y=c(P[2],A[2]),
                 xend=c(Q[1],B[1]), yend=c(Q[2],B[2]),
                 vector=c("PQ","AB"))

ggplot() +
  geom_segment(data=df, aes(x=x,y=y,xend=xend,yend=yend,color=vector),
               arrow=arrow(length=unit(0.2,"cm")), size=1.2) +
  coord_fixed() + ggtitle("Ejercicio 5: vectores PQ y AB") + theme_minimal()

# Solo paralelismo
paralelos <- abs(PQ[1]*AB[2]-PQ[2]*AB[1])==0

list(PQ=PQ, AB=AB, paralelos=paralelos)
## $PQ
## [1] 3 4
## 
## $AB
## [1]  8 -4
## 
## $paralelos
## [1] FALSE

Ejercicio 6 : No paralelos

P <- c(1,4); Q <- c(-3,5)
A <- c(5,7); B <- c(5,6)

PQ <- Q-P
AB <- B-A

df <- data.frame(x=c(P[1],A[1]), y=c(P[2],A[2]),
                 xend=c(Q[1],B[1]), yend=c(Q[2],B[2]),
                 vector=c("PQ","AB"))

ggplot() +
  geom_segment(data=df, aes(x=x,y=y,xend=xend,yend=yend,color=vector),
               arrow=arrow(length=unit(0.2,"cm")), size=1.2) +
  coord_fixed() + ggtitle("Ejercicio 6: vectores PQ y AB") + theme_minimal()

paralelos <- abs(PQ[1]*AB[2]-PQ[2]*AB[1])==0

list(PQ=PQ, AB=AB, paralelos=paralelos)
## $PQ
## [1] -4  1
## 
## $AB
## [1]  0 -1
## 
## $paralelos
## [1] FALSE

Ejercicio 7 : Paralelos

P <- c(2,3,-4); Q <- c(-1,3,5)
A <- c(-2,3,-1); B <- c(-11,3,-28)

PQ <- Q-P
AB <- B-A

scatter3D(x=c(P[1],Q[1],A[1],B[1]),
          y=c(P[2],Q[2],A[2],B[2]),
          z=c(P[3],Q[3],A[3],B[3]),
          colvar=NULL, pch=19, cex=1.5,
          main="Ejercicio 8: vectores en 3D")
arrows3D(x0=c(P[1],A[1]), y0=c(P[2],A[2]), z0=c(P[3],A[3]),
         x1=c(Q[1],B[1]), y1=c(Q[2],B[2]), z1=c(Q[3],B[3]),
         col=c("blue","red"), lwd=2, add=TRUE)

paralelos <- all(PQ != 0) && all(AB != 0) &&
             all(round(PQ/AB,5) == round(PQ[1]/AB[1],5))

list(PQ=PQ, AB=AB, paralelos=paralelos)
## $PQ
## [1] -3  0  9
## 
## $AB
## [1]  -9   0 -27
## 
## $paralelos
## [1] FALSE

Ejercicio 8 : Paralelos

P <- c(2,3,-4); Q <- c(-1,3,5)
A <- c(-2,3,-1); B <- c(-11,3,-28)

PQ <- Q-P
AB <- B-A

scatter3D(x=c(P[1],Q[1],A[1],B[1]),
          y=c(P[2],Q[2],A[2],B[2]),
          z=c(P[3],Q[3],A[3],B[3]),
          colvar=NULL, pch=19, cex=1.5,
          main="Ejercicio 8: vectores en 3D")
arrows3D(x0=c(P[1],A[1]), y0=c(P[2],A[2]), z0=c(P[3],A[3]),
         x1=c(Q[1],B[1]), y1=c(Q[2],B[2]), z1=c(Q[3],B[3]),
         col=c("blue","red"), lwd=2, add=TRUE)

paralelos <- all(PQ != 0) && all(AB != 0) &&
             all(round(PQ/AB,5) == round(PQ[1]/AB[1],5))

list(PQ=PQ, AB=AB, paralelos=paralelos)
## $PQ
## [1] -3  0  9
## 
## $AB
## [1]  -9   0 -27
## 
## $paralelos
## [1] FALSE

Ej.1: No equivalentes, no paralelos

Ej.2: Equivalentes y paralelos

Ej.3: No equivalentes, no paralelos

Ej.4: Equivalentes y paralelos

Ej.5: No paralelos

Ej.6: No paralelos

Ej.7: Paralelos

Ej.8: Paralelos