Inherits from SPPoolObject : NSObject
Conforms to NSCopying
Declared in SPPoint.h

Overview

The SPPoint class describes a two dimensional point or vector.

Tasks

Initialization

Methods

Properties

  •   x

    The x-Coordinate of the point.

    property
  •   y

    The y-Coordinate of the point.

    property
  •   length

    The distance to the origin (or the length of the vector).

    property
  •   lengthSquared

    The squared distance to the origin (or the squared length of the vector)

    property
  •   angle

    The angle between the positive x-axis and the point (in radians, CCW).

    property
  •   isOrigin

    Returns true if this point is in the origin (x and y equal zero).

    property

Properties

angle

The angle between the positive x-axis and the point (in radians, CCW).

@property (readonly) float angle

Discussion

The angle between the positive x-axis and the point (in radians, CCW).

Declared In

SPPoint.h

isOrigin

Returns true if this point is in the origin (x and y equal zero).

@property (readonly) BOOL isOrigin

Discussion

Returns true if this point is in the origin (x and y equal zero).

Declared In

SPPoint.h

length

The distance to the origin (or the length of the vector).

@property (readonly) float length

Discussion

The distance to the origin (or the length of the vector).

Declared In

SPPoint.h

lengthSquared

The squared distance to the origin (or the squared length of the vector)

@property (readonly) float lengthSquared

Discussion

The squared distance to the origin (or the squared length of the vector)

Declared In

SPPoint.h

x

The x-Coordinate of the point.

@property (nonatomic, assign) float x

Discussion

The x-Coordinate of the point.

Declared In

SPPoint.h

y

The y-Coordinate of the point.

@property (nonatomic, assign) float y

Discussion

The y-Coordinate of the point.

Declared In

SPPoint.h

Class Methods

angleBetweenPoint:andPoint:

Calculates the angle between two points.

+ (float)angleBetweenPoint:(SPPoint *)p1 andPoint:(SPPoint *)p2

Discussion

Calculates the angle between two points.

Declared In

SPPoint.h

distanceFromPoint:toPoint:

Calculates the distance between two points.

+ (float)distanceFromPoint:(SPPoint *)p1 toPoint:(SPPoint *)p2

Discussion

Calculates the distance between two points.

Declared In

SPPoint.h

interpolateFromPoint:toPoint:ratio:

Determines a point between two specified points. ratio = 0 -> p1, ratio = 1 -> p2

+ (SPPoint *)interpolateFromPoint:(SPPoint *)p1 toPoint:(SPPoint *)p2 ratio:(float)ratio

Discussion

Determines a point between two specified points. ratio = 0 -> p1, ratio = 1 -> p2

Declared In

SPPoint.h

point

Factory method.

+ (instancetype)point

Discussion

Factory method.

Declared In

SPPoint.h

pointWithPolarLength:angle:

Factory method.

+ (instancetype)pointWithPolarLength:(float)length angle:(float)angle

Discussion

Factory method.

Declared In

SPPoint.h

pointWithX:y:

Factory method.

+ (instancetype)pointWithX:(float)x y:(float)y

Discussion

Factory method.

Declared In

SPPoint.h

Instance Methods

addPoint:

Adds a point to the current point and returns the resulting point.

- (SPPoint *)addPoint:(SPPoint *)point

Discussion

Adds a point to the current point and returns the resulting point.

Declared In

SPPoint.h

convertToGLKVector

Creates a GLKit vector that is equivalent to this instance.

- (GLKVector2)convertToGLKVector

Discussion

Creates a GLKit vector that is equivalent to this instance.

Declared In

SPPoint.h

copyFromPoint:

Copies the values from another point into the current point.

- (void)copyFromPoint:(SPPoint *)point

Discussion

Copies the values from another point into the current point.

Declared In

SPPoint.h

dot:

Returns the dot-product of self and the given point.

- (float)dot:(SPPoint *)other

Discussion

Returns the dot-product of self and the given point.

Declared In

SPPoint.h

initWithPolarLength:angle:

Initializes a point with the distance and angle in respect to the origin.

- (instancetype)initWithPolarLength:(float)length angle:(float)angle

Discussion

Initializes a point with the distance and angle in respect to the origin.

Declared In

SPPoint.h

initWithX:y:

Initializes a point with its x and y components. Designated Initializer.

- (instancetype)initWithX:(float)x y:(float)y

Discussion

Initializes a point with its x and y components. Designated Initializer.

Declared In

SPPoint.h

invert

Returns a point that is the inverse (negation) of this point.

- (SPPoint *)invert

Discussion

Returns a point that is the inverse (negation) of this point.

Declared In

SPPoint.h

isEqualToPoint:

Compares two points.

- (BOOL)isEqualToPoint:(SPPoint *)other

Discussion

Compares two points.

Declared In

SPPoint.h

normalize

Returns a point that has the same direction but a length of one.

- (SPPoint *)normalize

Discussion

Returns a point that has the same direction but a length of one.

Declared In

SPPoint.h

perpendicular

Returns a perpendicular vector.

- (SPPoint *)perpendicular

Discussion

Returns a perpendicular vector.

Declared In

SPPoint.h

rotateBy:

Rotates the point by the given angle (in radians, CCW) and returns the resulting point.

- (SPPoint *)rotateBy:(float)angle

Discussion

Rotates the point by the given angle (in radians, CCW) and returns the resulting point.

Declared In

SPPoint.h

scaleBy:

Scales the point by a certain factor and returns the resulting point.

- (SPPoint *)scaleBy:(float)scalar

Discussion

Scales the point by a certain factor and returns the resulting point.

Declared In

SPPoint.h

setX:y:

Sets the members of the point to the specified values.

- (void)setX:(float)x y:(float)y

Discussion

Sets the members of the point to the specified values.

Declared In

SPPoint.h

subtractPoint:

Substracts a point from the current point and returns the resulting point.

- (SPPoint *)subtractPoint:(SPPoint *)point

Discussion

Substracts a point from the current point and returns the resulting point.

Declared In

SPPoint.h

truncateLength:

Returns a point truncated to length.

- (SPPoint *)truncateLength:(float)maxLength

Discussion

Returns a point truncated to length.

Declared In

SPPoint.h