expyriment.misc.geometry

The geometry module.

This module contains miscellaneous geometry functions for expyriment.

Functions

expyriment.misc.geometry.cartesian2polar(xy, radians=False)

Convert a cartesian coordinate (x,y) to a polar coordinate (radial, angle[degrees]).

Parameters:
xy(float, float)

cartesian coordinate (x,y)

radiansboolean

use radians instead of degrees for the angle

Returns:
polar(float, float)

polar coordinate (radial, angle[degrees])

expyriment.misc.geometry.coordinates2position(coordinates, surface_size=None)

Convert coordinates on the screen or surface to an Expyriment position.

Parameters:
coordinates(int, int)

coordinates (x,y) to convert

surface_size: (int, int), optional

size of the surface one which position is defined if None (default), the position will be calculated relative to the screen

Returns:
position[int, int]
expyriment.misc.geometry.lines_intersect(pa, pb, pc, pd)

Returns true if two line segments are intersecting

Parameters:
pamisc.geometry.XYPoint

point 1 of line 1

pbmisc.geometry.XYPoint

point 2 of line 1

pcmisc.geometry.XYPoint

point 1 of line 2

pbmisc.geometry.XYPoint

point 2 of line 2

Returns:
checkbool

True if lines intersect

expyriment.misc.geometry.lines_intersection_point(pa, pb, pc, pd)

Returns the intersection point of two lines (a-b) and (c-d)

Parameters:
pamisc.geometry.XYPoint

point 1 of line 1

pbmisc.geometry.XYPoint

point 2 of line 1

pcmisc.geometry.XYPoint

point 1 of line 2

pbmisc.geometry.XYPoint

point 2 of line 2

Returns:
intersec_point: misc.geometry.XYPoint

intersection point

expyriment.misc.geometry.points2vertices(points)

Returns vertex representation of the points (list of misc.XYPoints)

Parameters:
points(int, int)

list of points

Returns:
vtxlist

list of vertices

expyriment.misc.geometry.points_to_vertices(points)

OBSOLETE FUNCTION! Please use points2vertices!

expyriment.misc.geometry.polar2cartesian(polar, radians=False)

Convert a polar coordinate (radial, angle[degrees]) to a polar coordinate (x, y)

Parameters:
polar(float, float)

polar coordinate (radial, angle[degrees])

radiansboolean

use radians instead of degrees for the angle

Returns:
xy(float, float)

cartesian coordinate (x,y)

expyriment.misc.geometry.position2coordinate(coordinate, surface_size=None)

“OBSOLETE FUNCTION: Please use ‘position2coordinates’.

expyriment.misc.geometry.position2coordinates(position, surface_size=None)

Convert an Expyriment position to coordinates on the screen or surface.

Parameters:
position(int, int)

position (x,y) to convert

surface_size: (int, int), optional

size of the surface one which coordinates should be calculated if None (default), the coordinats will be calculated relative to the screen

Returns:
coordinates[int, int]
expyriment.misc.geometry.position2visual_angle(position, viewing_distance, monitor_size)

Convert an expyriment position (pixel) to a visual angle from center.

Parameters:
position(int, int)

position (x,y) to convert

viewing_distancenumeric

viewing distance in cm

monitior_sizenumeric

physical size of the monitor in cm (x, y)

Returns:
angle(float, float)

visual angle for x & y dimension

expyriment.misc.geometry.tuples2points(list_of_tuples)

Converts a list of tuples (x,y) to a list of misc.XYPoints

expyriment.misc.geometry.vertices_cross(size, line_width)

Returns a list of vertices describing a cross.

Parameters:
size(int, int)

xy, length of the horizontal (x) and vertical (y) line

line_widthint

width of the lines

Returns:
vtxlist of vertices

Notes

The resulting vertices can be plotted with the class stimuli.Shape(vertex_list=…).

expyriment.misc.geometry.vertices_frame(size, frame_thickness)

Returns a list of vertices describing a frame

Parameters:
size(int, int)

size (width, height) of the rectangle

frame_thicknessint

the thickness of the frame

Returns:
vtxlist of vertices

Notes

The resulting vertices can be plotted with the class stimuli.Shape(vertex_list=…).

expyriment.misc.geometry.vertices_parallelogram(angle, length1, length2)

Returns a list of vertices describing a parallelogram A, B, C, D.

   A --- B
  .     .
 .     .
D --- C
Parameters:
anglefloat

the angle between the lines AB and BC in degrees

length1float

the length between AB

length2float

the length between BC

Returns:
vtxlist of vertices

Notes

The resulting vertices can be plotted with the class stimuli.Shape(vertex_list=…).

expyriment.misc.geometry.vertices_rectangle(size)

Returns a list of vertices describing a rectangle.

Parameters:
size(int, int)

size (width, height) of the rectangle

Returns:
vtxlist of vertices

Notes

The resulting vertices can be plotted with the class stimuli.Shape(vertex_list=…).

expyriment.misc.geometry.vertices_regular_polygon(n_edges, length)

Returns a list of vertices describing a regular polygon.

Parameters:
n_edgesint

the number of edges

lengthfloat

the length of one side of the polygon

Returns:
vtxlist of vertices

Notes

The resulting vertices can be plotted with the class stimuli.Shape(vertex_list=…).

expyriment.misc.geometry.vertices_trapezoid(width_top, width_bottom, height)

Returns a list of vertices describing a trapezoid

Parameters:
width_top: int

width of the top edge

width_bottom: int

width of the bottom edge

heightint

height of the trapezoid

Returns:
vtxlist of vertices

Notes

The resulting vertices can be plotted with the class stimuli.Shape(vertex_list=…).

expyriment.misc.geometry.vertices_triangle(angle, length1, length2)

Returns a list of vertices describing a triangle A, B, C.

A --- B
     .
    .
   C
Parameters:
anglefloat

the angle between the lines AB and BC in degrees

length1float

the length between AB

length2float

the length between BC

Returns:
vtxlist of vertices

Notes

The resulting vertices can be plotted with the class stimuli.Shape(vertex_list=…).

expyriment.misc.geometry.visual_angle2position(visual_angle, viewing_distance, monitor_size)

Convert an position defined as visual angle from center to expyriment position (pixel).

Parameters:
visual_angle(numeric, numeric)

position in visual angle (x,y) to convert

viewing_distancenumeric

viewing distance in cm

monitior_size(numeric, numeric)

physical size of the monitor in cm (x, y)

Returns:
position(float, float)

position (x,y)