ladybug_geometry.geometry2d.ray module

2D Ray

class ladybug_geometry.geometry2d.ray.Ray2D(p, v)[source]

Bases: Base1DIn2D

2D Ray object.

Parameters
  • p – A Point2D representing the base of the ray.

  • v – A Vector2D representing the direction of the ray.

Properties:
  • p

  • v

  • min

  • max

ToString()

Overwrite .NET ToString.

closest_point(point)

Get the closest Point2D on this object to another Point2D.

Parameters

point – A Point2D object to which the closest point on this object will be computed.

Returns

Point2D for the closest point on this line to the input point.

distance_to_point(point)

Get the minimum distance between this object and the input point.

Parameters

point – A Point2D object to which the minimum distance will be computed.

Returns

The distance to the input point.

duplicate()

Get a copy of this object.

classmethod from_array(ray_array)[source]

Create a Ray2D from a nested array with a point and a vector.

Parameters

ray_array – Nested tuples ((p.x, p.y), (v.x, v.y)).

classmethod from_dict(data)

Create a LineSegment2D/Ray2D from a dictionary.

Parameters

data – A python dictionary in the following format

{
"p": (10, 0),
"v": (10, 10)
}
intersect_line_ray(line_ray)

Get the intersection between this object and another Ray2 or LineSegment2D.

Parameters

line_ray – Another LineSegment2D or Ray2D or to intersect.

Returns

Point2D of intersection if it exists. None if no intersection exists.

is_colinear(line_ray, tolerance, angle_tolerance=None)

Test whether this object is colinear to another LineSegment2D or Ray2D.

Parameters
  • line_ray – Another LineSegment2D or Ray2D for which co-linearity with this object will be tested.

  • tolerance – The maximum distance between the line_ray and the infinite extension of this object for them to be considered colinear.

  • angle_tolerance – The max angle in radians that the direction between this object and another can vary for them to be considered parallel. If None, the angle tolerance will not be used to evaluate co-linearity and the lines will only be considered colinear if the endpoints of one line are within the tolerance distance of the other line. (Default: None).

is_parallel(line_ray, angle_tolerance)

Test whether this object is parallel to another LineSegment2D or Ray2D.

Parameters
  • line_ray – Another LineSegment2D or Ray2D for which parallelization with this objects will be tested.

  • angle_tolerance – The max angle in radians that the direction between this object and another can vary for them to be considered parallel.

move(moving_vec)[source]

Get a ray that has been moved along a vector.

Parameters

moving_vec – A Vector2D with the direction and distance to move the ray.

reflect(normal, origin)[source]

Get a ray reflected across a plane with the input normal vector and origin.

Parameters
  • normal – A Vector2D representing the normal vector for the plane across which the ray will be reflected. THIS VECTOR MUST BE NORMALIZED.

  • origin – A Point2D representing the origin from which to reflect.

reverse()[source]

Get a copy of this ray that is reversed.

rotate(angle, origin)[source]

Get a ray that is rotated counterclockwise by a certain angle.

Parameters
  • angle – An angle for rotation in radians.

  • origin – A Point2D for the origin around which the ray will be rotated.

scale(factor, origin=None)[source]

Scale a ray by a factor from an origin point.

Parameters
  • factor – A number representing how much the ray should be scaled.

  • origin – A Point2D representing the origin from which to scale. If None, it will be scaled from the World origin (0, 0).

to_array()[source]

A nested array representing the start point and vector.

to_dict()[source]

Get Ray2D as a dictionary.

property max

A Point2D for the maximum bounding rectangle vertex around this geometry.

property min

A Point2D for the minimum bounding rectangle vertex around this geometry.

property p

Base point.

property v

Direction vector.