C4 Engine
C4 Engine API Documentation

class Point2D

Defined in:  TSVector2D.h
The Point2D class encapsulates a 2D point.
Definition

class Point2D : public Vector2D

Constructor

Point2D();

Point2D(float a, float b);

Parameters
a The value of the x coordinate.
b The value of the y coordinate.
Description
The Point2D class is used to store a two-dimensional point having floating-point coordinates x and y. The difference between a point and a vector is that a point is assumed to have a w coordinate of 1 whenever it needs to be converted to a four-dimensional representation, whereas a vector is assumed to have a w coordinate of 0. Such a conversion occurs when a vector or point is assigned to a Vector4D object or is multiplied by a Transform4D object.

The default constructor leaves the components of the vector undefined. If the values a and b are supplied, then they are assigned to the x and y coordinates of the base vector object, respectively.

The difference between two points produces a direction vector. A two-dimensional direction vector is converted to a point by adding it to the identifier Zero2D.
Overloaded Operators
Point2D& operator *=(float n); Multiplies by the scalar n.
Point2D& operator /=(float n); Divides by the scalar n.
Nonmember Operations
Point2D operator -(const Point2D& p); Returns the negation of the point p.
Point2D operator +(const Point2D& a, const Point2D& b); Returns the sum of the points a and b.
Point2D operator +(const Point2D& p, const Vector2D& v); Returns the sum of the point p and the vector v.
Point2D operator -(const Point2D& p, const Vector2D& v); Returns the difference of the point p and the vector v.
Vector2D operator -(const Point2D& a, const Point2D& b); Returns the difference of the points a and b.
Point2D operator *(const Point2D& p, float n); Returns the product of the point p and the scalar n.
Point2D operator *(float n, const Point2D& p); Returns the product of the point p and the scalar n.
Point2D operator /(const Point2D& p, float n) const; Returns the product of the point p and the inverse of the scalar n.
Point2D operator *(const Point2D& a, const Point2D& b); Returns the componentwise product of the points a and b.
Point2D operator *(const Point2D& p, const Vector2D& v); Returns the componentwise product of the point p and the vector v.
Point2D operator *(const Vector2D& v, const Point2D& p); Returns the componentwise product of the vector v and the point p.
Base Classes
Vector2D A Point2D object behaves much like a Vector2D object, but some properties are altered.
See Also

Vector2D

Vector4D