fabex.utilities.geom_utils#

Fabex ‘geom_utils.py’ © 2012 Vilem Novak

Main functionality of Fabex. The functions here are called with operators defined in ‘ops.py’

Classes#

Functions#

circle(r, np)

Generate a circle defined by a given radius and number of points.

helix(r, np, zstart, pend, rev)

Generate a helix of points in 3D space.

get_container()

Get or create a container object for CAM objects.

triangle(i, T, A)

s_sine(A, T[, dc_offset, phase_shift])

get_circle(r, z)

Generate a 2D array representing a circle.

get_circle_binary(r)

Generate a binary representation of a circle in a 2D grid.

Module Contents#

circle(r, np)[source]#

Generate a circle defined by a given radius and number of points.

This function creates a polygon representing a circle by generating a list of points based on the specified radius and the number of points (np). It uses vector rotation to calculate the coordinates of each point around the circle. The resulting points are then used to create a polygon object.

Parameters:
  • r (float) – The radius of the circle.

  • np (int) – The number of points to generate around the circle.

Returns:

A polygon object representing the circle.

Return type:

Polygon

helix(r, np, zstart, pend, rev)[source]#

Generate a helix of points in 3D space.

This function calculates a series of points that form a helix based on the specified parameters. It starts from a given radius and z-coordinate, and generates points by rotating around the z-axis while moving linearly along the z-axis. The number of points generated is determined by the number of turns (revolutions) and the number of points per revolution.

Parameters:
  • r (float) – The radius of the helix.

  • np (int) – The number of points per revolution.

  • zstart (float) – The starting z-coordinate for the helix.

  • pend (tuple) – A tuple containing the x, y, and z coordinates of the endpoint.

  • rev (int) – The number of revolutions to complete.

Returns:

A list of tuples representing the coordinates of the points in the

helix.

Return type:

list

get_container()[source]#

Get or create a container object for CAM objects.

This function checks if a container object named ‘CAM_OBJECTS’ exists in the current Blender scene. If it does not exist, the function creates a new empty object of type ‘PLAIN_AXES’, names it ‘CAM_OBJECTS’, and sets its location to the origin (0, 0, 0). The newly created container is also hidden. If the container already exists, it simply retrieves and returns that object.

Returns:

The container object for CAM objects, either newly created or

existing.

Return type:

bpy.types.Object

class Point(x, y, z)[source]#
triangle(i, T, A)[source]#
s_sine(A, T, dc_offset=0, phase_shift=0)[source]#
get_circle(r, z)[source]#

Generate a 2D array representing a circle.

This function creates a 2D NumPy array filled with a specified value for points that fall within a circle of a given radius. The circle is centered in the array, and the function uses the Euclidean distance to determine which points are inside the circle. The resulting array has dimensions that are twice the radius, ensuring that the entire circle fits within the array.

Parameters:
  • r (int) – The radius of the circle.

  • z (float) – The value to fill the points inside the circle.

Returns:

A 2D array where points inside the circle are filled with the value z, and points outside are filled with -10.

Return type:

numpy.ndarray

get_circle_binary(r)[source]#

Generate a binary representation of a circle in a 2D grid.

This function creates a 2D boolean array where the elements inside a circle of radius r are set to True, and the elements outside the circle are set to False. The circle is centered in the middle of the array, which has dimensions of (2*r, 2*r). The function iterates over each point in the grid and checks if it lies within the specified radius.

Parameters:

r (int) – The radius of the circle.

Returns:

A 2D boolean array representing the circle.

Return type:

numpy.ndarray