Arrow3D

Qualified name: algan.mobs.shapes\_3d.Arrow3D

class Arrow3D(start=tensor([-1., -0., -0.]), end=tensor([1., 0., 0.]), shaft_radius=0.02, tip_length=0.3, tip_radius=0.08, color=Color([1., 1., 1., 0., 1.]), resolution=24, *args, **kwargs)[source]

Bases: Mob

An arrow: a Cylinder shaft with a Cone tip, grouped.

Both parts are curved surfaces, so the arrow is tessellated per frame like the rest of the curved family.

Parameters:
  • start – Tail and head of the arrow, shape (*, 3) in world units. Default to LEFT and RIGHT.

  • end – Tail and head of the arrow, shape (*, 3) in world units. Default to LEFT and RIGHT.

  • shaft_radius (float) – Radius of the shaft, in world units. Defaults to 0.02.

  • tip_length (float) – Length of the conical tip, in world units, measured back from end. Defaults to 0.3.

  • tip_radius (float) – Radius of the tip’s base, in world units. Defaults to 0.08.

  • color – An Algan Color, a named constant such as BLUE, or anything Color() accepts. Defaults to WHITE.

  • resolution – Grid resolution for both parts, as (grid_width, grid_height) or one int for both. Defaults to 24.

  • *args – Passed to Mob.

  • **kwargs – Passed to Mob.

Raises:

ValueError – If the distance from start to end is not greater than tip_length, which would leave no room for a shaft.

Examples

An arrow pointing up and to the right:

Example: Example1Arrow3D

../_images/Example1Arrow3D-1.png
from algan import *

Arrow3D(start=LEFT + DOWN, end=RIGHT + UP, shaft_radius=0.04,
        color=BLUE).spawn()

Scene.save_video()

Methods

get_end

get_render_primitives

get_start

get_unit_vector

get_vector

Attributes

animation_manager

This mob's scene-owned animation manager.

basis

The Mob's orientation and scale, as a flattened 3x3 matrix of shape (*, 9).

casts_shadows

Whether this Mob's geometry blocks light on its way from a light source to another surface -- whether it casts a shadow.

children

The Mobs attached below this one, in attachment order.

closed_shell

Whether this Mob's triangles form a CLOSED shell -- every camera ray that enters the geometry crosses a second time on its way out.

draws_descendants

Whether get_render_primitives returns geometry belonging to this Mob's DESCENDANTS as well as its own.

forward

Get the direction the Mob is facing.

lifespan

This mob's [spawn, despawn) interval on its Scene timeline (a Lifespan).

location

The Mob's position in world space, shape (*, 3).

normalized_basis

The Mob's orientation with scale divided out, shape (*, 9).

parents

The Mobs this one is attached to, in attachment order.

receives_shadows

Whether this Mob's surfaces are darkened by shadows cast onto them.

right

Get the Mob's own rightward direction.

scale_coefficient

The Mob's scale along its own right, up and forward axes, shape (*, 3).

two_sided

Whether this Mob's geometry should be lit from whichever side the ray arrives on.

up

Get the Mob's own upward direction.

x

The Mob's x coordinate in world units, shape (*, 1).

xy

The Mob's x and y coordinates in world units, shape (*, 2).

y

The Mob's y coordinate in world units, shape (*, 1).

z

The Mob's z coordinate in world units, shape (*, 1).

draws_descendants = True

Whether get_render_primitives returns geometry belonging to this Mob’s DESCENDANTS as well as its own. Almost nothing does: a BezierCircuitCubic or a Surface draws its own rows and leaves its children to draw themselves. Polyhedron is the exception – it gathers every face under one _mesh_key – and the difference decides two things for become(): whether the Mob is one morph unit or several, and whether a descendant may be published to the Scene in its own right (doing so under an aggregator draws it twice, and draws geometry the aggregator deliberately omits, such as a Polyhedron’s vertex-and-edge graph).