ladybug_geometry.geometry3d.ray module

3D Ray

class ladybug_geometry.geometry3d.ray.Ray3D(p, v)[source]

Bases: Base1DIn3D

3D Ray object.

Parameters:
  • p – A Point3D representing the base of the ray.

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

Properties:
  • p

  • v

  • min

  • max

  • center

ToString()

Overwrite .NET ToString.

closest_point(point)

Get the closest Point3D on this object to another Point3D.

Parameters:

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

Returns:

Point3D for the closest point on this line/ray to the input point.

distance_to_point(point)

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

Parameters:

point – A Point3D 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 Ray3D 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 LineSegment3D/Ray3D from a dictionary.

Parameters:

data – A python dictionary in the following format

{
"p": (10, 0, 0),
"v": (10, 10, 0)
}
classmethod from_ray2d(ray2d, z=0)[source]

Initialize a new Ray3D from an Ray2D and a z value.

Parameters:
  • line2d – A Ray2D to be used to generate the Ray3D.

  • z – A number for the Z coordinate value of the line.

intersect_plane(plane)

Get the intersection between this object and a Plane.

Parameters:

plane – A Plane that will be intersected with this object.

Returns:

A Point3D object if the intersection was successful. None if no intersection exists.

is_colinear(line_ray, tolerance, angle_tolerance=None)

Test whether this object is colinear to another LineSegment3D or Ray3D.

Parameters:
  • line_ray – Another LineSegment3D or Ray3D 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 LineSegment3D or Ray3D.

Parameters:
  • line_ray – Another LineSegment3D or Ray3D 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 Vector3D 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 Vector3D representing the normal vector for the plane across which the ray will be reflected. THIS VECTOR MUST BE NORMALIZED.

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

reverse()[source]

Get a copy of this ray that is reversed.

rotate(axis, angle, origin)[source]

Rotate a ray by a certain angle around an axis and origin.

Right hand rule applies: If axis has a positive orientation, rotation will be clockwise. If axis has a negative orientation, rotation will be counterclockwise.

Parameters:
  • axis – A Vector3D axis representing the axis of rotation.

  • angle – An angle for rotation in radians.

  • origin – A Point3D for the origin around which the object will be rotated.

rotate_xy(angle, origin)[source]

Get a ray rotated counterclockwise in the XY plane by a certain angle.

Parameters:
  • angle – An angle in radians.

  • origin – A Point3D for the origin around which the object 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 Point3D representing the origin from which to scale. If None, it will be scaled from the World origin (0, 0, 0).

scale_world_origin(factor)[source]

Scale a ray by a factor from the world origin. Faster than Ray2D.scale.

Parameters:

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

to_array()[source]

A nested array representing the start point and vector.

to_dict()[source]

Get Ray3D as a dictionary.

property center

A Point3D for the center of the bounding box around this geometry.

property max

A Point3D for the maximum bounding box vertex around this geometry.

property min

A Point3D for the minimum bounding box vertex around this geometry.

property p

Base point.

property v

Direction vector.