# [−][src]Trait cgmath::MetricSpace

    pub trait MetricSpace: Sized {
        type Metric: BaseFloat;
        fn distance2(self, other: Self) -> Self::Metric;

        fn distance(self, other: Self) -> Self::Metric { ... }
    }

A type with a distance function between values.

Examples are vectors, points, and quaternions.

## Associated Types

### `type Metric: BaseFloat`

The metric to be returned by the `distance` function.

Loading content...

## Required methods

### `fn distance2(self, other: Self) -> Self::Metric`

Returns the squared distance.

This does not perform an expensive square root operation like in `MetricSpace::distance` method, and so can be used to compare distances more efficiently.

Loading content...

## Provided methods

### `fn distance(self, other: Self) -> Self::Metric`

The distance between two values.

Loading content...

## Implementors

### `impl<S: BaseFloat> MetricSpace for Point1<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

### `impl<S: BaseFloat> MetricSpace for Point2<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

### `impl<S: BaseFloat> MetricSpace for Point3<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

### `impl<S: BaseFloat> MetricSpace for Quaternion<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

### `impl<S: BaseFloat> MetricSpace for Vector1<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

### `impl<S: BaseFloat> MetricSpace for Vector2<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

### `impl<S: BaseFloat> MetricSpace for Vector3<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

### `impl<S: BaseFloat> MetricSpace for Vector4<S>`[src]

#### `type Metric = S`

#### `fn distance2(self, other: Self) -> S`[src]

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)