Learn R Programming

triangulation (version 0.5.0)

determine_position: Determine position of observer

Description

Determine the position of an observer based on angles between three known points as seen by the observer. At least two angles must be provided - preferably observer_angle_AB and observer_angle_AC (since this combination allows for solutions outside the triangle formed by the points A, B and C)

Usage

determine_position(A, B, C, observer_angle_AB, observer_angle_AC, observer_angle_BC = NA, output_plot = TRUE, lines_in_plot = TRUE, coordinates_in_plot = TRUE, decimals_in_plot = 2)

Arguments

A
A point defined by a vector containing an x- and an y-coordinate
B
A point defined by a vector containing an x- and an y-coordinate
C
A point defined by a vector containing an x- and an y-coordinate
observer_angle_AB
An angle (numeric) expressed in radians (or alternatively the symbol NA)
observer_angle_AC
An angle (numeric) expressed in radians (or alternatively the symbol NA)
observer_angle_BC
An angle (numeric) expressed in radians (or alternatively the symbol NA)
output_plot
Boolean variable indicating whether a plot should be created
lines_in_plot
Boolean variable indicating whether lines should be drawn in the plot
coordinates_in_plot
Boolean variable indicating whether the coordinates should be printet in the plot
decimals_in_plot
Integer indicating the number of decimals used

Value

Coordinates indicating the observers position. Note that several solutions might exist.

Examples

Run this code
determine_position(A = c(0, 0), B = c(10, 0), C = c(5, 5 * 3^0.5), observer_angle_AB = pi * 2/3,
observer_angle_AC = pi * 1/2)

determine_position(A = c(0, 0), B = c(10, 0), C = c(5, 5), observer_angle_AB = pi * 5/6,
observer_angle_AC = pi * 1/2, observer_angle_BC = NA, lines_in_plot = FALSE)

determine_position(A = c(0, 0), B = c(10, 0), C = c(5, 5), observer_angle_AB = pi * 5/6,
observer_angle_AC = pi * 1/2, observer_angle_BC = pi * 2/3, lines_in_plot = FALSE)

Run the code above in your browser using DataLab