Ficheiro:Trigonometry exercise 1.svg

Ficheiro original(ficheiro SVG, de 540 × 540 píxeis, tamanho: 14 kB)

Descrição do ficheiro editar

Trigonometry exercise. Code written in R.

Function to plot the triangle:


trigonometry.triangle <- function(f, angle, side, unknown)
{
  # draw an exercise triangle,
  # whose purpose if to solve it using function "f"
  # with known angle and side
  # ex: trigonometry.triangle("sin", "60", "2", "x")
  # is an exercise to find x using formula x = 2 sin(60)

  #
  # plan the triangle
  #
  B <- as.double(angle) * pi/180

  if (f == "sin" || f == "cos") {
    a <- as.double(side)
    b <- a * sin(B)
    c <- a * cos(B)
  } else if (f == "cosec" || f == "cotan") {
    b <- as.double(side)
    a <- b / sin(B)
    c <- b / tan(B)
  } else if (f == "sec" || f == "tan") {
    c <- as.double(side)
    a <- c / cos(B)
    b <- c * tan(B)
  }

  #
  # define the triangle (A,B,C)
  #
  pt.x <- c(0, -c, 0, 0)
  pt.y <- c(0, 0, b, 0)
  max.bc <- max(b, c)
  x.lim <- c(-0.7, 0.7) * max.bc - c/2
  y.lim <- c(-0.7, 0.7) * max.bc + b/2

  # plot and add notations
  par(mar=c(0,0,0,0)) # reset margins
  plot(0, xlim=x.lim, ylim=y.lim, col="white")
  par(usr=c(x.lim, y.lim))

  # plot triangle
  points(pt.x, pt.y, type="l", col="black")
  # plot angle
  theta <- seq(0, B, pi/180)
  points(-c + (a/4) * cos(theta), (a/4) * sin(theta), type="l", col="red")
  # display names of vertices
  text(max.bc * 0.1, 0, "A", col="black")
  text(-c - max.bc * 0.1, 0, "B", col="black")
  text(max.bc * 0.1, b, "C", col="black")
  text(-c + (a/3) * cos(B/2), (a/3) * sin(B/2), angle, col="black")
  # display known side
  if (f == "sin" || f == "cos") {
    text(-c/2 + 0.1 * max.bc, b/2 + 0.1 * max.bc, side, col="black")
  } else if (f == "cosec" || f == "cotan") {
    text(max.bc * 0.1, b/2, side, col="black")
  } else if (f == "sec" || f == "tan") {
    text(-c/2, - max.bc * 0.1, side, col="black")
  }
  # display unknown side
  if (f == "sec" || f == "cosec") {
    text(-c/2 + 0.1 * max.bc, b/2 + 0.1 * max.bc, unknown, col="black")
  } else if (f == "sin" || f == "tan") {
    text(max.bc * 0.1, b/2, unknown, col="black")
  } else if (f == "cos" || f == "cotan") {
    text(-c/2, - max.bc * 0.1, unknown, col="black")
  }
}

Code to plot this triangle:

  library(Cairo)
  CairoSVG("Trigonometry_exercise_1.svg")
  trigonometry.triangle("sin", 30, 15, "x")
  dev.off()

Licença: editar

Public domain Eu, o autor deste trabalho, neste momento o libero como de domínio público. Isto é aplicável em todo o mundo.

Em caso disto não ser legalmente possível:
Eu cedo a qualquer pessoa o direito de usar este trabalho para qualquer propósito, sem qualquer restrição, a menos que estas condições sejam requeridas pela lei.

Histórico do ficheiro

Clique uma data e hora para ver o ficheiro tal como ele se encontrava nessa altura.

Data e horaMiniaturaDimensõesUtilizadorComentário
atual13h08min de 14 de agosto de 2008Miniatura da versão das 13h08min de 14 de agosto de 2008540 × 540 (14 kB)Albmont (discussão | contribs)Trigonometry exercise. Code written in R. Function to plot the triangle: <pre> trigonometry.triangle <- function(f, angle, side, unknown) { # draw an exercise triangle, # whose purpose if to solve it using function "f" # with known angle and side