rotate_point: Rotate coordinates

Description Usage Arguments Value Examples

View source: R/plot_MTG.R

Description

Rotate coordinates

Usage

1
rotate_point(x0, y0, x1, y1, angle)

Arguments

x0

x coordinate of the origin

y0

y coordinate of the origin

x1

x coordinate of the point

y1

y coordinate of the point

angle

Rotation angle in degree (anti-clockwise)

Value

The new coordinates for the point

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
rotate_point(0,0,1,0,90)

# Example with a plot:
x0 = 1 ; y0 = 1 ; x1= 2 ; y1= 2 ;x3= 3 ; y3= 3
plot(c(x0,x1),c(y0,y1), type="l", ylim = c(0,3), xlim = c(0,3))
segments(x1,y1,x3,y3, col= 2)
segments(x1,y1,rotate_point(x1,y1,x3,y3, 45)[1],rotate_point(x1,y1,x3,y3, 45)[2], col= 3)

## End(Not run)

VEZY/XploRer documentation built on Oct. 9, 2021, 10:05 p.m.