Options
All
  • Public
  • Public/Protected
  • All
Menu

Module turtlesoup

Index

Functions

  • chordLength(radius: number, angle: number): number
  • Determine the length of a chord of a circle. (There is a simple formula; derive it or look it up.)

    Parameters

    • radius: number

      radius of a circle, must be > 0

    • angle: number

      in degrees, where 0 <= angle < 180

    Returns number

    the length of the chord subtended by the given angle in a circle of the given radius

  • Calculate the distance between two points.

    Parameters

    Returns number

    Euclidean distance between p1 and p2

  • drawApproximateCircle(turtle: Turtle, radius: number, numSides: number): void
  • Approximate a circle by drawing a many-sided regular polygon, using only right-hand turns, and restoring the turtle's original heading and position after the drawing is complete.

    Parameters

    • turtle: Turtle

      the turtle context

    • radius: number

      radius of the circle circumscribed around the polygon, must be > 0

    • numSides: number

      number of sides of the polygon to draw, must be >= 10

    Returns void

  • drawPersonalArt(turtle: Turtle): void
  • Draw your personal, custom art.

    Many interesting images can be drawn using the simple implementation of a turtle. See the problem set handout for more information.

    Parameters

    • turtle: Turtle

      the turtle context

    Returns void

  • drawSquare(turtle: Turtle, sideLength: number): void
  • Draw a square.

    Parameters

    • turtle: Turtle

      the turtle context

    • sideLength: number

      length of each side, must be >= 0

    Returns void

  • Given a set of points, find a shortest path that connects the points.

    Parameters

    • points: Set<Point>

      input points

    Returns Point[]

    an array containing all the input points, in an order that minimizes the total length of the line segments from each point to its successor in the array (i.e., minimizing the sum of the distances from array[i] to array[i+1] for all adjacent indices i,i+1 in the array)

  • Given three non-collinear points, calculate the incenter (center of the inscribed circle) of the triangle with vertices at those points.

    Parameters

    • p1: Point

      one point

    • p2: Point

      another point

    • p3: Point

      a third point which is not collinear with p1 and p2

    Returns Point

    the center of the circle inscribed in the triangle whose vertices are p1, p2, p3.

Generated using TypeDoc