Struct geo::Point [] [src]

pub struct Point(pub Coordinate);

Methods

impl Point
[src]

fn new(x: f64, y: f64) -> Point

Creates a new point.

use geo::Point;

let p = Point::new(1.234, 2.345);

assert_eq!(p.x(), 1.234);
assert_eq!(p.y(), 2.345);

fn x(&self) -> f64

Returns the x/horizontal component of the point.

use geo::Point;

let p = Point::new(1.234, 2.345);

assert_eq!(p.x(), 1.234);

fn set_x(&mut self, x: f64) -> &mut Point

Sets the x/horizontal component of the point.

use geo::Point;

let mut p = Point::new(1.234, 2.345);
p.set_x(9.876);

assert_eq!(p.x(), 9.876);

fn y(&self) -> f64

Returns the y/vertical component of the point.

use geo::Point;

let p = Point::new(1.234, 2.345);

assert_eq!(p.y(), 2.345);

fn set_y(&mut self, y: f64) -> &mut Point

Sets the y/vertical component of the point.

use geo::Point;

let mut p = Point::new(1.234, 2.345);
p.set_y(9.876);

assert_eq!(p.y(), 9.876);

fn lng(&self) -> f64

Returns the longitude/horizontal component of the point.

use geo::Point;

let p = Point::new(1.234, 2.345);

assert_eq!(p.lng(), 1.234);

fn set_lng(&mut self, lng: f64) -> &mut Point

Sets the longitude/horizontal component of the point.

use geo::Point;

let mut p = Point::new(1.234, 2.345);
p.set_lng(9.876);

assert_eq!(p.lng(), 9.876);

fn lat(&self) -> f64

Returns the latitude/vertical component of the point.

use geo::Point;

let p = Point::new(1.234, 2.345);

assert_eq!(p.lat(), 2.345);

fn set_lat(&mut self, lat: f64) -> &mut Point

Sets the latitude/vertical component of the point.

use geo::Point;

let mut p = Point::new(1.234, 2.345);
p.set_lat(9.876);

assert_eq!(p.lat(), 9.876);

fn dot(&self, point: &Point) -> f64

Returns the dot product of the two points: dot = x1 * x2 + y1 * y2

use geo::Point;

let p = Point::new(1.5, 0.5);
let dot = p.dot(&Point::new(2.0, 4.5));

assert_eq!(dot, 5.25);

Trait Implementations

impl Debug for Point
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Copy for Point
[src]

impl Clone for Point
[src]

fn clone(&self) -> Point

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl PartialEq for Point
[src]

fn eq(&self, __arg_0: &Point) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Point) -> bool

This method tests for !=.

impl Neg for Point
[src]

type Output = Point

The resulting type after applying the - operator

fn neg(self) -> Point

Returns a point with the x and y components negated.

use geo::Point;

let p = -Point::new(-1.25, 2.5);

assert_eq!(p.x(), 1.25);
assert_eq!(p.y(), -2.5);

impl Add for Point
[src]

type Output = Point

The resulting type after applying the + operator

fn add(self, _rhs: Point) -> Point

Add a point to the given point.

use geo::Point;

let p = Point::new(1.25, 2.5) + Point::new(1.5, 2.5);

assert_eq!(p.x(), 2.75);
assert_eq!(p.y(), 5.0);

impl Sub for Point
[src]

type Output = Point

The resulting type after applying the - operator

fn sub(self, _rhs: Point) -> Point

Subtract a point from the given point.

use geo::Point;

let p = Point::new(1.25, 3.0) - Point::new(1.5, 2.5);

assert_eq!(p.x(), -0.25);
assert_eq!(p.y(), 0.5);