Class GPoint

This class represents a point in 2-dimensional space. This class is used primarily for recording and handling mouse locations. However, it may also be used for geometry calculations in conjunction with GMatrix.

Constructor

GPoint(x=0, y=0)

Constructor: Creates a new GPoint value (x,y).

All values are 0.0 by default.

Parameter:x – initial x value

Precondition: value is an int or float.

Parameter:y – initial y value

Precondition: value is an int or float.

Attributes

x

The x coordinate of the point.

Invariant: Must be an int or float.

y

The y coordinate of the point.

Invariant: Must be an int or float.

Methods

The class GPoint has overloaded the operations + and - to allow point point addition and subtraction. It also supports scalar multiplication via * on both the right and the left.

list()

Returns: A python list with the contents of this GPoint.

interpolate(other, alpha)

Returns: the interpolation of self and other via alpha.

The value returned has the same type as self (so it is either a GPoint or is a subclass of GPoint). The contents of this object are not altered. The resulting value is

alpha*self+(1-alpha)*other

according to GPoint addition and scalar multiplication.

Parameter:other – tuple value to interpolate with

Precondition: value has the same type as self.

Parameter:alpha – scalar to interpolate by

Precondition: value is an int or float.

distanceTo(other)

Returns: the Euclidean distance from this point to other

Parameter:other – value to compare against

Precondition: value is a Tuple3D object.