Version: 14

# viktor.geometry

## Arc​

class viktor.geometry.Arc(centre_point, start_point, end_point, short_arc=True, *, n_segments=30, color=Color(0, 0, 0), identifier=None)

Creates a constant radius arc in the xy plane. Clockwise rotation creates an outward surface.

Parameters:
• centre_point (`Union`[`Point`, `Tuple`[`float`, `float`, `float`]]) – Point in xy plane.

• start_point (`Union`[`Point`, `Tuple`[`float`, `float`, `float`]]) – Point in xy plane. Should have the same distance to centre_point as end_point.

• end_point (`Union`[`Point`, `Tuple`[`float`, `float`, `float`]]) – Point in xy plane. Should have the same distance to centre_point as start_point.

• short_arc (`bool`) – Angle of arc smaller than pi if True, larger than pi if False.

• n_segments (`int`) – Number of discrete segments of the arc (default: 30)

New in v13.5.0
.

• color (`Color`) – Visualization color

New in v13.5.0
.

• identifier (`str`) – object identifier (new in v14.10.0)

property centre_point: Point
property start_point: Point
property end_point: Point
property n_segments: int
property theta1_theta2: Tuple[float, float]

Angles of the end (theta1) and start (theta2) points with respect to the x-axis in radians.

property theta1: float

Angle of the end point with respect to the x-axis in radians.

property theta2: float

Angle of the start point with respect to the x-axis in radians.

property short_arc: bool
property angle: float

Absolute angle of the arc in radians, which is the difference between theta1 and theta2.

property length: float

Arc length.

discretize(num=2)

Returns a discrete representation of the arc, as a list of Point objects. The amount of points can be specified using ‘num’, which should be larger than 1.

Return type:

`List`[`Point`]

revolve(*, rotation_angle=None, material=None, identifier=None, **kwargs)

Returns an ArcRevolve object, revolved around the global y-axis.

Parameters:
• rotation_angle (`float`) – Angle of the revolved object according to the right-hand-rule, with the start of the rotation in positive z-direction. Angle in radians. If not specified, 2 pi will be used.

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

Return type:

`ArcRevolve`

## ArcExtrusion​

class viktor.geometry.ArcExtrusion(profile, arc, profile_rotation=0, n_segments=50, *, material=None, identifier=None)

Bases: `Group`

Given an Arc and a cross-section of the extrusion, a discretized Extrusion object is returned.

The coordinates of the profile are defined with respect to the Arc and have a LOCAL coordinate system:

• z-axis is in direction of the arc from start to end.

• x-axis is in positive global z-axis.

• y-axis follows from the right-hand-rule.

Rotation of the profile is about the axis according to the right-hand-rule with LOCAL z-axis (see definition above).

Example:

```profile = [
Point(1, 1),
Point(1, 2),
Point(3, 2),
Point(3, 1),
Point(1, 1),
]
arc = Arc(Point(1, 1, 0), Point(3, 1, 0), Point(1, 3, 0))
arc_ext = ArcExtrusion(profile, arc, profile_rotation=10, n_segments=10)
```

This will result in the following visualization, where the Arc itself is also shown in the xy plane:

Parameters:
• profile (`List`[`Point`]) – Coordinates of cross-section.

• arc (`Arc`) – An Arc object is used to define the direction of the extrusion.

• profile_rotation (`float`) – Rotation of the profile around its local Z-axis in degrees.

• n_segments (`int`) – Number of discrete segments of the arc, which is 50 by default.

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

## ArcRevolve​

class viktor.geometry.ArcRevolve(arc, *args, rotation_angle=None, material=None, identifier=None, **kwargs)

Bases: `Revolve`

Returns a revolved object of an arc around the global y-axis.

In the example below, rotation_angle is equal to pi / 3:

Parameters:
• arc (`Arc`) – Arc object.

• rotation_angle (`float`) – Angle of the revolved object according to the right-hand-rule, with the start of the rotation in positive z-direction. Angle in radians. If not specified, 2 pi will be used.

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

property arc: Arc

`Arc`

property uuid: str
property surface_area: float

Total exterior area of the object.

property inner_volume: float

Returns the inner volume of the revolved object.

This method will only return a value if the defined Arc meets the following conditions:

• it should be short, i.e. short_arc=True

• the start- and end-point are located on the same side w.r.t. the y-axis of the center-point of the Arc

• it is defined in clockwise direction

property height: float

Height of the object.

## BidirectionalPattern​

class viktor.geometry.BidirectionalPattern(base_object, direction_1, direction_2, number_of_elements_1, number_of_elements_2, spacing_1, spacing_2, *, identifier=None)

Bases: `Pattern`

Instantiates a two-dimensional pattern, evenly spaced in two separate directions. If identifier has been set on the base-object, the identifiers of the objects within the pattern are suffixed with ‘-i’ (i = 1, 2, 3, …).

Parameters:
• base_object (`TransformableObject`) – the object to be duplicated

• direction_1 (`List`[`float`]) – a unit vector specifying the first direction

• direction_2 (`List`[`float`]) – a unit vector specifying the second direction

• number_of_elements_1 (`int`) – total amount of elements along direction 1

• number_of_elements_2 (`int`) – total amount of elements along direction 2

• spacing_1 (`float`) – the applied spacing in direction 1

• spacing_2 (`float`) – the applied spacing in direction 2

• identifier (`str`) – object identifier (new in v14.10.0)

## CartesianAxes​

class viktor.geometry.CartesianAxes(origin=Point(0.000e+00, 0.000e+00, 0.000e+00), axis_length=1, axis_diameter=0.05)

Bases: `Group`

Helper visualisation object to show positive x (red), y (green) and z (blue) axes.

Parameters:
• origin (`Point`) – Coordinates of the origin.

• axis_length (`float`) – Length of the axes.

• axis_diameter (`float`) – Diameter of the axes.

## CircularExtrusion​

class viktor.geometry.CircularExtrusion(diameter, line, *, shell_thickness=None, material=None, identifier=None)

This class is used to construct an extrusion which has a circular base, e.g. a circular foundation pile.

Parameters:
• diameter (`float`) – Outer diameter of the cross-section.

• line (`Line`) – Line object along which the circular cross-section is extruded.

• shell_thickness (`float`) – Optional shell thickness. None for solid (default: None)

New in v13.6.0
.

• material (`Material`) – Optional material.

• identifier (`str`) – object identifier (new in v14.10.0)

property line: Line
property length: float
property diameter: float
property shell_thickness: float | None
property cross_sectional_area: float

## Cone​

class viktor.geometry.Cone(diameter, height, *, origin=None, orientation=None, material=None, identifier=None)

Creates a cone object.

Parameters:
• diameter (`float`) – Diameter of the circular base surface.

• height (`float`) – Height from base to tip.

• origin (`Point`) – Optional location of the centroid of the base surface (default: Point(0, 0, 0)).

• orientation (`Vector`) – Optional orientation from origin to the tip (default: Vector(0, 0, 1)).

• material (`Material`) – Optional material.

• identifier (`str`) – object identifier (new in v14.10.0)

classmethod from_line(diameter, line, *, material=None, identifier=None)

Create a Cone object by a given base diameter and line.

Parameters:
• diameter (`float`) – Diameter of the circular base surface.

• line (`Line`) – Line from base to top of the cone. The start point of the line represents the location of the center of the base, and the end point represents the tip of the cone.

• material (`Material`) – Optional material.

• identifier (`str`) – object identifier (new in v14.10.0)

Return type:

`Cone`

## Extrusion​

class viktor.geometry.Extrusion(profile, line, profile_rotation=0, *, material=None, identifier=None)

Bases: `Group`

Extruded object from a given set of points, which is called the profile. This profile should meet the following requirements:

• start point should be added at the end for closed profile

• points should be defined in z=0 plane

• circumference should be defined clockwise

Note that the profile is defined with respect to the start point of the Line object, i.e. the profile is defined in the local coordinate system. An example is given below of two extrusions with the same dimensions. Their corresponding Line objects are also visualized. The extrusion have the following profile:

```# black box
profile_b = [
Point(1, 1),
Point(1, 2),
Point(2, 2),
Point(2, 1),
Point(1, 1),
]
box_b = Extrusion(profile_b, Line(Point(4, 1, 0), Point(4, 1, 1)))

# yellow box
profile_y = [
Point(-0.5, -0.5),
Point(-0.5, 0.5),
Point(0.5, 0.5),
Point(0.5, -0.5),
Point(-0.5, -0.5),
]
box_y = Extrusion(profile_y, Line(Point(2, 2, 0), Point(2, 2, 1)))
```
Parameters:
• profile (`List`[`Point`]) – Coordinates of cross-section.

• line (`Line`) – A line object is used to define the length (thickness) of the extrusion.

• profile_rotation (`float`) – Rotation of the profile around the Z-axis in degrees.

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

property profile: List[Point]
property material: Material
property line: Line
property length: float

## GeoPoint​

class viktor.geometry.GeoPoint(lat, lon)

Geographical point on the Earth’s surface described by a latitude / longitude coordinate pair.

This object can be created directly, or will be returned in the params when using a `GeoPointField`.

Parameters:
• lat (`float`) – Latitude, between -90 and 90 degrees.

• lon (`float`) – Longitude, between -180 and 180 degrees.

classmethod from_rd(coords)

Instantiates a GeoPoint from the provided RD coordinates.

Parameters:

coords (`Tuple`[`float`, `float`]) – RD coordinates (x, y).

Return type:

`GeoPoint`

property rd: Tuple[float, float]

RD representation (x, y) of the GeoPoint.

## GeoPolygon​

class viktor.geometry.GeoPolygon(*points)

Geographical polygon on the Earth’s surface described by a list of `GeoPoints`.

This object can be created directly, or will be returned in the params when using a `GeoPolygonField`.

Parameters:

points (`GeoPoint`) – Geo points (minimum 3). The profile is automatically closed, so it is not necessary to add the start point at the end.

property points: List[GeoPoint]

## GeoPolyline​

class viktor.geometry.GeoPolyline(*points)

Geographical polyline on the Earth’s surface described by a list of `GeoPoints`.

This object can be created directly, or will be returned in the params when using a `GeoPolylineField`.

Parameters:

points (`GeoPoint`) – Geo points (minimum 2).

property points: List[GeoPoint]

## Group​

class viktor.geometry.Group(objects, *, identifier=None)
Parameters:
• objects (`Sequence`[`TransformableObject`]) – Objects that are part of the group.

• identifier (`str`) – object identifier (new in v14.10.0)

Return type:

`None`

property children: List[TransformableObject]
duplicate()
Return type:

`Group`

## Line​

class viktor.geometry.Line(start_point, end_point, *, color=Color(0, 0, 0), identifier=None)
Parameters:
• start_point (`Union`[`Point`, `Tuple`[`float`, `float`, `float`]]) – Start point of the line (cannot coincide with end_point).

• end_point (`Union`[`Point`, `Tuple`[`float`, `float`, `float`]]) – End point of the line (cannot coincide with start_point).

• color (`Color`) – Visualization color

New in v13.5.0
.

• identifier (`str`) – object identifier (new in v14.10.0)

property start_point: Point
property end_point: Point
property length: float
direction(normalize=True)

Direction vector between start and end point.

Return type:

`Vector`

collinear(point)

True if point is collinear (in line) with Line, else False.

Return type:

`bool`

project_point(point)

Project the point on the (unbounded) line.

Return type:

`Point`

distance_to_point(point)

Calculate the (minimal) distance from the given point to the (unbounded) line.

Return type:

`float`

property length_vector: numpy.ndarray
property unit_vector: numpy.ndarray
property horizontal: bool
property vertical: bool
revolve(*, material=None, identifier=None, **kwargs)

Revolve line around y-axis, only possible for lines in x-y plane.

Parameters:
• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

Raises:

NotImplementedError – when line is not in x-y plane

Return type:

`LineRevolve`

get_line_function_parameters()

Get parameters for y=ax+b definition of a line.

Return type:

`Tuple`[`float`, `float`]

Returns:

(a, b) or (nan, nan) if line is vertical

find_overlap(other, inclusive=False)

Find the overlapping part of this line with another line.

The returned value depends on the situation:

• None, if no overlap is found or the two lines are not parallel

• Point, if an overlap is found with length equal to 0

• Line, if an overlap is found with length larger than 0

Parameters:
• other (`Line`) – Other Line object

• inclusive (`bool`) – True to treat overlapping points as overlap

Return type:

`Union`[`Point`, `Line`, `None`]

## LineRevolve​

class viktor.geometry.LineRevolve(line, *args, material=None, identifier=None, **kwargs)

Bases: `Revolve`

Returns a revolved object of a Line around the global y-axis.

An example revolve of a line between the point (1, 1, 0) and (3, 2, 0) is shown below, with the line object shown in black.

```line = Line(Point(1, 1, 0), Point(3, 2, 0))
line_rev = LineRevolve(line)
```
Parameters:
property line: Line
property uuid: UUID
property height: float
property surface_area: float

Returns the total exterior area of the revolved object.

property inner_volume: float

Returns the inner volume of the revolved object.

This method will only return a value if the defined Line meets the following conditions:

• it should NOT be horizontal, i.e. y_start != y_end

• it should be defined in positive y-direction, i.e. y_start < y_end

## LinearPattern​

class viktor.geometry.LinearPattern(base_object, direction, number_of_elements, spacing, *, identifier=None)

Bases: `Pattern`

Instantiates a linear, evenly spaced, pattern along a single direction. If identifier has been set on the base-object, the identifiers of the objects within the pattern are suffixed with ‘-i’ (i = 1, 2, 3, …).

Parameters:
• base_object (`TransformableObject`) – the object to be duplicated

• direction (`List`[`float`]) – a unit vector specifying in which direction the pattern propagates

• number_of_elements (`int`) – total amount of elements in the pattern, including the base object

• spacing (`float`) – the applied spacing

• identifier (`str`) – object identifier (new in v14.10.0)

## Material​

class viktor.geometry.Material(name=None, density=None, price=None, *, threejs_type='MeshStandardMaterial', roughness=1.0, metalness=0.5, opacity=1.0, color=Color(221, 221, 221))

Note

The following properties were renamed since v14.5.0. If you are using a lower version, please use the old naming.

• threejs_roughness -> roughness

• threejs_metalness -> metalness

• threejs_opacity -> opacity

Parameters:
• name (`str`) – Optional name.

• density (`float`) – Optional density.

• price (`float`) – Optional price.

• threejs_type (`str`) – deprecated

• roughness (`float`) – Between 0 - 1 where closer to 1 gives the material a rough texture.

• metalness (`float`) – Between 0 - 1 where closer to 1 gives the material a shiny metal look.

• opacity (`float`) – Between 0 - 1 where closer to 0 makes the material less visible.

• color (`Color`) – Color of the material.

## Pattern​

class viktor.geometry.Pattern(base_object, duplicate_translation_list, *, identifier=None)

Bases: `Group`

Instantiates a pattern based on a base object and several duplicates, each translated by an input vector. If identifier has been set on the base-object, the identifiers of the objects within the pattern are suffixed with ‘-i’ (i = 1, 2, 3, …).

Parameters:
• base_object (`TransformableObject`) – the object to be duplicated

• duplicate_translation_list (`List`[`List`[`float`]]) – a list of translation vectors, each of which generates a duplicate

• identifier (`str`) – object identifier (new in v14.10.0)

## Point​

class viktor.geometry.Point(x, y, z=0)

This class represents a point object, which is instantiated by means of 3-dimensional coordinates X, Y, and Z. It forms a basis of many structural 2D and 3D objects.

Example usage:

```p1 = Point(1, 2)        # create a 2D point
p1.z                    # 0
p2 = Point(1, 2, 3)     # create a 3D point
p1.z                    # 3
```
Parameters:
• x (`float`) – X-coordinate.

• y (`float`) – Y-coordinate.

• z (`float`) – (optional) Z-coordinate, defaults to 0.

Raises:

TypeError – if the point is instantiated with a None value.

property x: float

X-coordinate.

property y: float

Y-coordinate.

property z: float

Z-coordinate.

property coordinates: numpy.ndarray

Coordinates of the Point as array (X, Y, Z).

copy()

Returns a deep copy of the object.

Return type:

`Point`

coincides_with(other)

Given another Point object, this method determines whether the two points coincide.

Return type:

`bool`

vector_to(point)

Vector pointing from self to point.

Example usage:

```p1 = Point(1, 2, 3)
p2 = Point(0, 0, 0)         # origin
v = p1.vector_to(p2)        # vector from p1 to the origin
v = p1.vector_to((0, 0, 0)) # short notation
```
Return type:

`Vector`

get_local_coordinates(local_origin, spherical=False)

Method to determine the local coordinates of the current Point with respect to a ‘local origin’.

Return type:

`ndarray`

## Polygon​

class viktor.geometry.Polygon(points, *, surface_orientation=False, material=None, skip_duplicate_vertices_check=False, identifier=None)

2D closed polygon without holes in x-y plane.

Parameters:
• points (`List`[`Point`]) – profile is automatically closed, do not add start point at the end. only the x and y coordinates are considered. left hand rule around circumference determines surface direction

• surface_orientation (`bool`) –

• if True, the left hand rule around circumference determines surface direction

• if False, surface always in +z direction

• material (`Material`) – optional material

• skip_duplicate_vertices_check (`bool`) – if True, duplicate vertices are not filtered on serialization of the triangles. This may boost performance (default: False).

• identifier (`str`) – object identifier (new in v14.10.0)

Raises:

ValueError

• if less than 3 points are provided.

• if points contains duplicates.

• if points form a polygon with self-intersecting lines.

• if points are all collinear.

has_clockwise_circumference()
Return type:

`bool`

Method determines the direction of the input points, and returns:
• True if the circumference is clockwise

• False if the circumference is counter-clockwise

property cross_sectional_area: float
property centroid: Tuple[float, float]

Returns the centroid (X, Y) of the polygon.

property moment_of_inertia: Tuple[float, float]

Returns the moment of inertia (Ix, Iy) in xy-plane.

extrude(line, *, profile_rotation=0, material=None, identifier=None)

Extrude the Polygon in the direction of the given line. Polygon must be defined in clockwise direction.

Parameters:
• line (`Line`) – A line object is used to define the length (thickness) of the extrusion.

• profile_rotation (`float`) – Rotation of the profile around the Z-axis in degrees.

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

Raises:

ValueError – if polygon is defined in anti-clockwise direction

Return type:

`Extrusion`

## Polyline​

class viktor.geometry.Polyline(points, *, color=Color(0, 0, 0), identifier=None)

Representation of a polyline made up of multiple straight line segments.

This class is immutable, meaning that all functions that perform changes on a polyline will return a mutated copy of the original polyline.

Parameters:
• points (`List`[`Point`]) – List of points, which may contain duplicate points. Note that when calling the individual lines of the polyline, duplicate points are filtered (i.e. zero-length lines are omitted).

• color (`Color`) – Visualization color

New in v13.5.0
.

• identifier (`str`) – object identifier (new in v14.10.0)

property points: List[Point]
classmethod from_lines(lines)

Create a polyline object from a list of lines.

The end of one line must always coincide with the start of the next line.

Parameters:

lines (`Sequence`[`Line`]) – Sequence of lines

Return type:

`Polyline`

is_equal_to(other)

Check if all points in this polyline coincide with all points of another polyline

Parameters:

other (`Polyline`) – Other polyline

Return type:

`bool`

property start_point: Point

First point in polyline.points

property end_point: Point

Last point in polyline.points

property lines: List[Line]

A list of lines connecting all polyline points. Lines between coincident points are skipped.

property x_min: float | None

The lowest x-coordinate present within this polyline.

property x_max: float | None

The highest x-coordinate present within this polyline.

property y_min: float | None

The lowest y-coordinate present within this polyline.

property y_max: float | None

The highest y-coordinate present within this polyline.

property z_min: float | None

The lowest z-coordinate present within this polyline.

property z_max: float | None

The highest z-coordinate present within this polyline.

get_reversed_polyline()

Returns a polyline that is the reverse of this one.

Return type:

`Polyline`

serialize()

Return a json serializable dict of form:

```[
{'x': point_1.x, 'y': point_1.y},
{'x': point_2.x, 'y': point_2.y}
]
```
Return type:

`List`[`dict`]

filter_duplicate_points()

Returns a new Polyline object. If two consecutive points in this polyline coincide, the second point will be omitted

Return type:

`Polyline`

is_monotonic_ascending_x(strict=True)

Check if the x coordinates of the points of this polyline are ascending.

Parameters:

strict (`bool`) – when set to false, equal x coordinates are accepted between points

Return type:

`bool`

is_monotonic_ascending_y(strict=True)

Check if the y coordinates of the points of this polyline are ascending

Parameters:

strict (`bool`) – when set to false, equal y coordinates are accepted between points

Return type:

`bool`

intersections_with_polyline(other_polyline)

Find all intersections with another polyline and return them ordered according to the direction of this polyline

If the polylines are partly parallel, the start and end points of the parallel section will be returned as intersections. If one of the polylines is a subset of the other, or the two lines are completely parallel, no intersections will be found.

Parameters:

other_polyline (`Polyline`) –

Return type:

`List`[`Point`]

intersections_with_x_location(x)

Find all intersections of this polyline with a given x location. Ordered from start to end of this polyline.

If this line is partly vertical, the start and end points of the vertical section will be returned as an intersection. If this line is completely vertical, no intersections will be found.

Parameters:

x (`float`) –

Return type:

`List`[`Point`]

point_is_on_polyline(point)

Check if a given point lies on this polyline

Parameters:

point (`Point`) –

Return type:

`bool`

get_polyline_between(start_point, end_point, inclusive=False)

Given two points that both lie on a polyline, return the polyline that lies between those two points start_point has to lie before end_point on this polyline.

If the given start point lies after the given end point on this polyline, an empty polyline will be returned. If the two given points are identical, it depends on the inclusive flag whether a polyline containing that point once, or an empty polyline will be returned.

Parameters:
Raises:

ValueError – when one of the two given points does not lie on this polyline

Return type:

`Polyline`

find_overlaps(other)

Find all overlapping regions of this polyline with another polyline. The returned overlapping regions will all point in the direction of this line. The overlap polylines will contain all points of both polylines, even if they only occur in one of the lines.

If no overlaps are found, an empty list will be returned.

Parameters:

other (`Polyline`) –

Return type:

`List`[`Polyline`]

combine_with(other)

Given two polylines that have at least one point in common and together form one line without any side branches, combine those two polylines. The combined line will contain all points of both polylines.

Parameters:

other (`Polyline`) –

Return type:

`Polyline`

split(point)

return the two separate parts of this polyline before and after the given point.

Parameters:

point (`Point`) –

Raises:

ValueError – if the provided point does not lie on this polyline.

Return type:

`Tuple`[`Polyline`, `Polyline`]

classmethod get_lowest_or_highest_profile_x(profile_1, profile_2, lowest)

Given two polylines with n intersections, return a third polyline that will always follow the lowest (or highest) of the two lines the x locations of the points of the two polylines should be not descending (lines from left to right or vertical) the returned polyline will only cover the overlapping range in x coordinates.

If one of the profiles is an empty polyline, an empty polyline will be returned.

examples:

```                                   /----------------|
/         /-------|--------------------
profile_1: ----------------\     /         /        |
\   /         /         |_____________________________
profile_2:      -------------\-/         /
\_________/

get_lowest_or_highest_profile_x(cls, profile_1, profile_2, lowest=True) will return:

/-------|
/        |
/         |____________________
result:     -------------\           /
\_________/
```

Note that only the overlapping region of the two profiles is returned!

Parameters:
Return type:

`Polyline`

Currently, this implementation is exclusive. Meaning that vertical line parts that lie on the start or end of the overlap region in x are not taken into account.

## RDWGSConverter​

class viktor.geometry.RDWGSConverter

Class that provides functions to translate latitude and longitude coordinates between the WGS system and RD system.

The RD coordinate system is a cartesian coordinate system that is frequently used for in civil engineering to describe locations in the Netherlands. The origin is located in france, so that for all of the Netherlands, both x (m) and y (m) values are positive and y is always larger then x. The domain in which the RD coordinate system is valid is:

• x: [-7000, 300000]

• y: [289000, 629000]

About the RD coordinate system: https://nl.wikipedia.org/wiki/Rijksdriehoeksco%C3%B6rdinaten

X0 = 155000
Y0 = 463000
phi0 = 52.1551744
lam0 = 5.38720621
static from_rd_to_wgs(coords)

Convert RD coordinates (x, y) to WGS coordinates [latitude, longitude].

```lat, lon = RDWGSConverter.from_rd_to_wgs((100000, 400000))
```
Parameters:

coords (`Tuple`[`float`, `float`]) – RD coordinates (x, y)

Return type:

`List`[`float`]

static from_wgs_to_rd(coords)

Convert WGS coordinates (latitude, longitude) to RD coordinates [x, y].

```x, y = RDWGSConverter.from_wgs_to_rd((51.58622, 4.59360))
```
Parameters:

coords (`Tuple`[`float`, `float`]) – WGS coordinates (latitude, longitude)

Return type:

`List`[`float`]

## RectangularExtrusion​

class viktor.geometry.RectangularExtrusion(width, height, line, profile_rotation=0, *, material=None, identifier=None)

Bases: `Extrusion`

Extruded object from a given set of points, which is called the profile. This profile should meet the following requirements:

• start point should be added at the end for closed profile

• points should be defined in z=0 plane

• circumference should be defined clockwise

Note that the profile is defined with respect to the start point of the Line object, i.e. the profile is defined in the local coordinate system. An example is given below of two extrusions with the same dimensions. Their corresponding Line objects are also visualized. The extrusion have the following profile:

```# black box
profile_b = [
Point(1, 1),
Point(1, 2),
Point(2, 2),
Point(2, 1),
Point(1, 1),
]
box_b = Extrusion(profile_b, Line(Point(4, 1, 0), Point(4, 1, 1)))

# yellow box
profile_y = [
Point(-0.5, -0.5),
Point(-0.5, 0.5),
Point(0.5, 0.5),
Point(0.5, -0.5),
Point(-0.5, -0.5),
]
box_y = Extrusion(profile_y, Line(Point(2, 2, 0), Point(2, 2, 1)))
```
Parameters:
• profile – Coordinates of cross-section.

• line (`Line`) – A line object is used to define the length (thickness) of the extrusion.

• profile_rotation (`float`) – Rotation of the profile around the Z-axis in degrees.

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

property width: float

Width of the extrusion.

property height: float

Height of the extrusion.

property cross_sectional_area: float

Returns the area of the cross-section (width x height).

property inner_volume: float

Returns the inner volume of the extruded object.

## Revolve​

class viktor.geometry.Revolve(*args, rotation_angle=None, material=None, identifier=None, **kwargs)

Bases: `TransformableObject`, `ABC`

Abstract base class of a revolved object.

abstract property surface_area: float
abstract property inner_volume: float
property thickness: float
property mass: float

Calculates the mass of the object as rho * area * thickness, with rho the density of the Material.

## Sphere​

class viktor.geometry.Sphere(centre_point, radius, width_segments=30, height_segments=30, material=None, *, identifier=None)

This class can be used to construct a spherical object around the specified coordinate.

The smoothness of the edges can be altered by setting width_segments and height_segments. In the example below both the default smoothness of 30 (left) and a rough sphere with 5 segments (right) is shown:

Parameters:
• centre_point (`Point`) – Center point of the sphere.

• radius (`float`) – Radius of the sphere.

• width_segments (`float`) – Sets the smoothness in xz-plane.

• height_segments (`float`) – Sets the smoothness in yz-plane.

• material (`Material`) – Optionally a custom material can be set.

• identifier (`str`) – object identifier (new in v14.10.0)

diameter()
Return type:

`float`

circumference()
Return type:

`float`

surface_area()
Return type:

`float`

volume()
Return type:

`float`

## SquareBeam​

class viktor.geometry.SquareBeam(length_x, length_y, length_z, *, material=None, identifier=None)

High level object to create a rectangular beam object around the origin. The centroid of the beam is located at the origin (0, 0, 0).

Parameters:
• length_x (`float`) – Width of the extrusion in x-direction.

• length_y (`float`) – Length of the extrusion in y-direction.

• length_z (`float`) – Height of the extrusion in z-direction.

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

## Torus​

class viktor.geometry.Torus(radius_cross_section, radius_rotation_axis, rotation_angle=6.283185307179586, *, material=None, identifier=None)

Bases: `Group`

Create a torus object

Parameters:
• radius_cross_section (`float`) –

• radius_rotation_axis (`float`) – measured from central axis to centre of cross-section.

• rotation_angle (`float`) – optional argument to control how large of a torus section you want. 2pi for complete torus

• material (`Material`) – optional material

• identifier (`str`) – object identifier (new in v14.10.0)

property inner_volume: float
property material: Material

## TransformableObject​

class viktor.geometry.TransformableObject(*, identifier=None)

Bases: `ABC`

translate(translation_vector)

Translate an object along a translation vector.

Parameters:

translation_vector (`Union`[`Vector`, `Tuple`[`float`, `float`, `float`]]) – Vector along which translation is to be performed.

Return type:

`TransformableObject`

rotate(angle, direction, point=None)

Rotate an object along an axis (direction) by an angle. Direction will follow right hand rule.

Parameters:
• angle (`float`) – Angle of desired rotation in radians.

• direction (`Union`[`Vector`, `Tuple`[`float`, `float`, `float`]]) – Vector along which rotation is to be performed.

• point (`Union`[`Point`, `Tuple`[`float`, `float`, `float`]]) – Point through which the rotation vector runs.

Return type:

`TransformableObject`

mirror(point, normal)

Mirror an object on a plane defined by a point and normal vector.

Parameters:
• point (`Union`[`Point`, `Tuple`[`float`, `float`, `float`]]) – Point within the mirror plane.

• normal (`Union`[`Vector`, `Tuple`[`float`, `float`, `float`]]) – Normal vector of the mirror plane.

Return type:

`TransformableObject`

scale(scaling_vector)

Scale an object along a scaling vector.

Parameters:

scaling_vector (`Union`[`Vector`, `Tuple`[`float`, `float`, `float`]]) – Vector along which scaling is to be performed.

Return type:

`TransformableObject`

## Triangle​

class viktor.geometry.Triangle(point1, point2, point3)

Creates a Triangle object from 3D vertices.

Parameters:
area()

Returns the area of the triangle.

Return type:

`float`

property centroid: Tuple[float, float, float]

Returns the centroid (X, Y, Z) of the triangle.

property moment_of_inertia: Tuple[float, float]

Returns the moment of inertia (Ix, Iy) (only in x-y plane).

## TriangleAssembly​

class viktor.geometry.TriangleAssembly(triangles, *, material=None, skip_duplicate_vertices_check=False, identifier=None)

Fundamental visualisation geometry, built up from triangles. Right hand rule on triangle circumference determines the surface direction.

Parameters:
• triangles (`List`[`Triangle`]) – Triangles of the assembly.

• material (`Material`) – optional material.

• skip_duplicate_vertices_check (`bool`) – if True, duplicate vertices are not filtered on serialization of the triangles. This may boost performance (default: False).

• identifier (`str`) – object identifier (new in v14.10.0)

## Vector​

class viktor.geometry.Vector(x, y, z=0)

A 3-dimensional vector in space.

The following operations are supported:

• Negation

```v1 = Vector(1, 2, 3)
v2 = -v1  # results in Vector(-1, -2, -3)
```

```v1 = Vector(1, 2, 3)
v2 = Vector(1, 2, 3)
v3 = v1 + v2  # results in Vector(2, 4, 6)
```
• Subtraction

```v1 = Vector(1, 2, 3)
v2 = Vector(1, 2, 3)
v3 = v1 - v2  # results in Vector(0, 0, 0)
```
• (reverse) Multiplication

```v1 = Vector(1, 2, 3)
v2 = v1 * 3  # results in Vector(3, 6, 9)
v3 = 3 * v1  # results in Vector(3, 6, 9)
```
• Dot product

```v1 = Vector(1, 2, 3)
v2 = Vector(1, 2, 3)
res = v1.dot(v2)  # results in 14
```
• Cross product

```v1 = Vector(1, 0, 0)
v2 = Vector(0, 1, 0)
v3 = v1.cross(v2)  # results in Vector(0, 0, 1)
```
Parameters:
• x (`float`) – X-coordinate.

• y (`float`) – Y-coordinate.

• z (`float`) – Z-coordinate (default: 0).

property squared_magnitude: float

Vector magnitude without square root; faster than magnitude.

property magnitude: float

Magnitude of the Vector.

property coordinates: Tuple[float, float, float]

Coordinates of the Vector as tuple (X, Y, Z).

normalize()

Return the normalized vector (with unit-length).

Raises:

ValueError – if vector is a null-vector.

Return type:

`Vector`

dot(other)

Scalar product of two vectors.

Parameters:

other (`Vector`) – Second Vector

Return type:

`float`

cross(other)

Vector product of two vectors.

Parameters:

other (`Vector`) – Second Vector

Return type:

`Vector`