psychopy.layout
 For working with vectors and points¶Classes and functions for working with coordinates systems.

Class representing a vector. 

Class representing a position vector. 

Class representing a size. 

Class representing an array of vertices. 
Class representing a vector.
A vector is a mathematical construct that specifies a length (or magnitude) and direction within a given coordinate system. This class provides methods to manipulate vectors and convert them between coordinates systems.
This class may be used to assist in positioning stimuli on a screen.
value (ArrayLike) – Array of vector lengths along each dimension of the space the vector is within. Vectors are specified as either 1xN for single vectors, and Nx2 or Nx3 for multiple vectors.
units (str or None) – Units which value has been specified in. Applicable values are ‘pix’, ‘deg’, ‘degFlat’, ‘degFlatPos’, ‘cm’, ‘pt’, ‘norm’, ‘height’, or None.
win (~psychopy.visual.Window or None) – Window associated with this vector. This value must be specified if you wish to map vectors to coordinate systems that require additional information about the monitor the window is being displayed on.
Examples
Create a new vector object using coordinates specified in pixel (‘pix’) units:
my_vector = Vector([256, 256], 'pix')
Multiple vectors may be specified by supplying a list of vectors:
my_vector = Vector([[256, 256], [640, 480]], 'pix')
Operators can be used to compare the magnitudes of vectors:
mag_is_same = vec1 == vec2 # same magnitude
mag_is_greater = vec1 > vec2 # one greater than the other
1xN vectors return a boolean value while Nx2 or Nx3 arrays return Nlength arrays of boolean values.
Values in units of ‘cm’ (centimeters).
Values in units of ‘deg’ (degrees of visual angle).
Values in units of ‘degFlat’ (degrees of visual angle corrected for screen curvature).
When dealing with positions/sizes in isolation; ‘deg’, ‘degFlat’ and ‘degFlatPos’ are synonymous  as the conversion is done at the vertex level.
Values in units of ‘degFlatPos’.
When dealing with positions/sizes in isolation; ‘deg’, ‘degFlat’ and ‘degFlatPos’ are synonymous  as the conversion is done at the vertex level.
How many dimensions (x, y, z) are specified?
Direction of vector (i.e. angle between vector and the horizontal plane).
Value in units of ‘height’ (normalized to the height of the window).
Magnitude of vector (i.e. length of the line from vector to (0, 0) in pixels).
The monitor used for calculations within this object (~psychopy.monitors.Monitor).
Value in units of ‘norm’ (normalized device coordinates).
Values in units of ‘pix’ (pixels).
Vector coordinates in ‘pt’ (points).
Points are commonly used in print media to define text sizes. One point is equivalent to 1/72 inches, or around 0.35 mm.
Class representing a position vector.
This class is used to specify the location of a point within some coordinate system (e.g., (x, y)).
value (ArrayLike) – Array of coordinates representing positions within a coordinate system. Positions are specified in a similar manner to ~psychopy.layout.Vector as either 1xN for single vectors, and Nx2 or Nx3 for multiple positions.
units (str or None) – Units which value has been specified in. Applicable values are ‘pix’, ‘deg’, ‘degFlat’, ‘degFlatPos’, ‘cm’, ‘pt’, ‘norm’, ‘height’, or None.
win (~psychopy.visual.Window or None) – Window associated with this position. This value must be specified if you wish to map positions to coordinate systems that require additional information about the monitor the window is being displayed on.
Values in units of ‘cm’ (centimeters).
Create a copy of this object
Values in units of ‘deg’ (degrees of visual angle).
Values in units of ‘degFlat’ (degrees of visual angle corrected for screen curvature).
When dealing with positions/sizes in isolation; ‘deg’, ‘degFlat’ and ‘degFlatPos’ are synonymous  as the conversion is done at the vertex level.
Values in units of ‘degFlatPos’.
When dealing with positions/sizes in isolation; ‘deg’, ‘degFlat’ and ‘degFlatPos’ are synonymous  as the conversion is done at the vertex level.
How many dimensions (x, y, z) are specified?
Direction of vector (i.e. angle between vector and the horizontal plane).
Value in units of ‘height’ (normalized to the height of the window).
Magnitude of vector (i.e. length of the line from vector to (0, 0) in pixels).
The monitor used for calculations within this object (~psychopy.monitors.Monitor).
Value in units of ‘norm’ (normalized device coordinates).
Values in units of ‘pix’ (pixels).
Vector coordinates in ‘pt’ (points).
Points are commonly used in print media to define text sizes. One point is equivalent to 1/72 inches, or around 0.35 mm.
Class representing a size.
value (ArrayLike) – Array of values representing size axisaligned bounding box within a coordinate system. Sizes are specified in a similar manner to ~psychopy.layout.Vector as either 1xN for single vectors, and Nx2 or Nx3 for multiple positions.
units (str or None) – Units which value has been specified in. Applicable values are ‘pix’, ‘deg’, ‘degFlat’, ‘degFlatPos’, ‘cm’, ‘pt’, ‘norm’, ‘height’, or None.
win (~psychopy.visual.Window or None) – Window associated with this size object. This value must be specified if you wish to map sizes to coordinate systems that require additional information about the monitor the window is being displayed on.
Values in units of ‘cm’ (centimeters).
Create a copy of this object
Values in units of ‘deg’ (degrees of visual angle).
Values in units of ‘degFlat’ (degrees of visual angle corrected for screen curvature).
When dealing with positions/sizes in isolation; ‘deg’, ‘degFlat’ and ‘degFlatPos’ are synonymous  as the conversion is done at the vertex level.
Values in units of ‘degFlatPos’.
When dealing with positions/sizes in isolation; ‘deg’, ‘degFlat’ and ‘degFlatPos’ are synonymous  as the conversion is done at the vertex level.
How many dimensions (x, y, z) are specified?
Direction of vector (i.e. angle between vector and the horizontal plane).
Value in units of ‘height’ (normalized to the height of the window).
Magnitude of vector (i.e. length of the line from vector to (0, 0) in pixels).
The monitor used for calculations within this object (~psychopy.monitors.Monitor).
Value in units of ‘norm’ (normalized device coordinates).
Values in units of ‘pix’ (pixels).
Vector coordinates in ‘pt’ (points).
Points are commonly used in print media to define text sizes. One point is equivalent to 1/72 inches, or around 0.35 mm.
Class representing an array of vertices.
verts (ArrayLike) – Array of coordinates specifying the locations of vertices.
obj (object or None) –
size (ArrayLike or None) – Scaling factors for vertices along each dimension.
pos (ArrayLike or None) – Offset for vertices along each dimension.
units (str or None) – Units which verts has been specified in. Applicable values are ‘pix’, ‘deg’, ‘degFlat’, ‘degFlatPos’, ‘cm’, ‘pt’, ‘norm’, ‘height’, or None.
flip (ArrayLike or None) – Array of boolean values specifying which dimensions to flip/mirror. Mirroring is applied prior to any other transformation.
anchor (str or None) – Anchor location for vertices, specifies the origin for the vertices.
Anchor location (str).
Possible values are on of ‘top’, ‘bottom’, ‘left’, ‘right’, ‘center’. Combinations of these values may also be specified (e.g., ‘top_center’, ‘centerright’, ‘topleft’, etc. are all valid).
Map anchor values to numeric vertices adjustments.
Get absolute positions of vertices in ‘cm’ units.
Get absolute positions of vertices in ‘deg’ units.
Get absolute positions of vertices in ‘degFlat’ units.
1x2 array for flipping vertices along each axis; set as True to flip or False to not flip (ArrayLike).
If set as a single value, will duplicate across both axes. Accessing the protected attribute (._flip) will give an array of 1s and 1s with which to multiply vertices.
Apply horizontal mirroring (bool)?
Apply vertical mirroring (bool)?
Get absolute positions of vertices in ‘height’ units.
Get absolute positions of vertices in ‘norm’ units.
Get absolute positions of vertices in ‘pix’ units.
Positional offset of the vertices (~psychopy.layout.Vector or ArrayLike).
Scaling factors for vertices (~psychopy.layout.Vector or ArrayLike).
Units which the vertices are specified in (str).