# EILOrientedLineSegment Class Reference

Inherits from | NSObject |
---|---|

Conforms to | NSCoding |

Declared in | EILOrientedLineSegment.h EILOrientedLineSegment.m |

## Overview

Represents a geometrical line segment with additional information about orientation. Object is immutable.

## Other Methods

` point1`

Coordinates of the first end point of the line segment.

`@property (nonatomic, strong, readonly) EILPoint *point1`

#### Declared In

`EILOrientedLineSegment.h`

` point2`

Coordinates of the second end point of the line segment.

`@property (nonatomic, strong, readonly) EILPoint *point2`

#### Declared In

`EILOrientedLineSegment.h`

` orientation`

Orientation associated with the line segment. If not defined takes EIL_ORIENTATION_UNDEFINED value. Value is in degrees, counted clockwise.

`@property (nonatomic, assign, readonly) double orientation`

#### Declared In

`EILOrientedLineSegment.h`

## Creating and Initializing Line Segments

`– initWithPoint1:point2:orientation:`

Returns a new oriented line segment object.

`- (instancetype)initWithPoint1:(EILPoint *)`*point1* point2:(EILPoint *)*point2* orientation:(double)*orientation*

#### Parameters

`point1` |
An EILPoint object representing first end point of the line segment. |
---|---|

`point2` |
An EILPoint object representing second end point of the line segment. |

`orientation` |
Orientation of the line segment. |

#### Return Value

A line segment initialized with (point1, point2, orientation).

#### Declared In

`EILOrientedLineSegment.h`

`+ lineWithPoint1:point2:orientation:`

Returns a new oriented line segment object.

`+ (instancetype)lineWithPoint1:(EILPoint *)`*point1* point2:(EILPoint *)*point2* orientation:(double)*orientation*

#### Parameters

`point1` |
An EILPoint object representing first end point of the line segment. |
---|---|

`point2` |
An EILPoint object representing second end point of the line segment. |

`orientation` |
Orientation of the line segment. |

#### Return Value

A line segment initialized with (point1, point2, orientation).

#### Declared In

`EILOrientedLineSegment.h`

`+ lineWithX1:y1:x2:y2:orientation:`

Returns a new oriented line segment object.

`+ (instancetype)lineWithX1:(double)`*x1* y1:(double)*y1* x2:(double)*x2* y2:(double)*y2* orientation:(double)*orientation*

#### Parameters

`x1` |
A x coordinate of the first end point of the line segment. |
---|---|

`y1` |
An y coordinate of the first end point of the line segment. |

`x2` |
A x coordinate of the second end point of the line segment. |

`y2` |
An y coordinate of the second end point of the line segment. |

`orientation` |
Orientation of the line segment. |

#### Return Value

A line segment initialized with ((x1,y1), (x2,y2), orientation).

#### Declared In

`EILOrientedLineSegment.h`

`+ lineWithLine:`

Returns a new oriented line segment object based on the given oriented line segment.

`+ (instancetype)lineWithLine:(EILOrientedLineSegment *)`*line*

#### Parameters

`line` |
An oriented line segment. |
---|

#### Return Value

An oriented line initialized with (line.point1, line.point2, line.orientation).

#### Declared In

`EILOrientedLineSegment.h`

## Operations on line segment

`– centerPoint`

Calculates a center point of the line. Has the same orientation as the line segment.

`- (EILOrientedPoint *)centerPoint`

#### Return Value

A new oriented point representing center of the line segment.

#### Declared In

`EILOrientedLineSegment.h`

`– leftPoint`

Calculates left point of the line.

`- (EILOrientedPoint *)leftPoint`

#### Return Value

An oriented point representing left point of the line. It will have the same orientation as the line.

#### Discussion

If the orientation of the line is pointing at you, the left point will be on the left.

If the line does not have an orientation nil will be returned.

#### Declared In

`EILOrientedLineSegment.h`

`– rightPoint`

Calculates right point of the line.

`- (EILOrientedPoint *)rightPoint`

#### Return Value

An oriented point representing right point of the line. It will have the same orientation as the line.

#### Discussion

If the orientation of the line is pointing at you, the right point will be on the right.

If the line does not have an orientation nil will be returned.

#### Declared In

`EILOrientedLineSegment.h`

`– length`

Calculates length of the line segment.

`- (double)length`

#### Return Value

A length of the line.

#### Declared In

`EILOrientedLineSegment.h`

`– lineTranslatedBydX:dY:`

Translates the line segment by a given vector (dX, dY) and returns a new line segment.

`- (EILOrientedLineSegment *)lineTranslatedBydX:(double)`*dX* dY:(double)*dY*

#### Parameters

`dX` |
Value of translation on X axis. |
---|---|

`dY` |
Value of translation on Y axis. |

#### Return Value

A new line segment translated by (dX, dY).

#### Declared In

`EILOrientedLineSegment.h`

## Serialization

`+ lineFromDictionary:`

Deserializes an oriented line segment from `NSDictionary`

.

`+ (nullable EILOrientedLineSegment *)lineFromDictionary:(NSDictionary *)`*dict*

#### Parameters

`dict` |
NSDictionary to deserialize from. |
---|

#### Return Value

An oriented line segment created from NSDictionary.

#### Declared In

`EILOrientedLineSegment.h`

`– toDictionary`

Serializes the oriented line segment to `NSDictionary`

.

`- (NSDictionary *)toDictionary`

#### Return Value

An oriented line segment representation in NSDictionary.

#### Declared In

`EILOrientedLineSegment.h`

## Identifying and Comparing Objects

`– isEqual:`

Returns a boolean value that indicates whether given oriented line segment is equal to this one.

`- (BOOL)isEqual:(nullable id)`*other*

#### Parameters

`other` |
The object to be compared to this oriented line segment. May be nil. |
---|

#### Return Value

YES if oriented line segments are equal, otherwise NO.

#### Declared In

`EILOrientedLineSegment.h`

`– isEqualToOrientedLine:`

`- (BOOL)isEqualToOrientedLine:(nullable EILOrientedLineSegment *)`*line*

#### See Also

#### Declared In

`EILOrientedLineSegment.h`

`– hash`

Returns an integer that can be used as a table address in a hash table structure.

`- (NSUInteger)hash`

#### Declared In

`EILOrientedLineSegment.h`

## Describing Objects

`– description`

Returns a string representation of the receiver.

`- (NSString *)description`

#### Return Value

A string representation of the oriented line segment in form of ((x1,y1),(x2,y2), orientation)

#### Declared In

`EILOrientedLineSegment.h`

## Encoding and Decoding

`– initWithCoder:`

Returns an oriented line segment initialized from data in a given unarchiver.

`- (nullable instancetype)initWithCoder:(NSCoder *)`*decoder*

#### Parameters

`decoder` |
An unarchiver object. |
---|

#### Return Value

A new oriented line segment initialized using the data in decoder.

#### Declared In

`EILOrientedLineSegment.h`

`– encodeWithCoder:`

Encodes the oriented line segment using a given archiver.

`- (void)encodeWithCoder:(NSCoder *)`*coder*

#### Parameters

`An` |
archiver object. |
---|

#### Declared In

`EILOrientedLineSegment.h`