toolbox3d

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2020 License: BSD-2-Clause Imports: 5 Imported by: 5

Documentation

Overview

Package toolbox3d provides a collection of parts for building practical 3D models for 3D prints.

Index

Constants

View Source
const (
	AxisX = 0
	AxisY = 1
	AxisZ = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis int

type AxisPinch added in v0.2.4

type AxisPinch struct {
	// The axis to pinch along.
	Axis Axis

	// Bounds on the axis to pinch.
	Min float64
	Max float64

	// Power controls how much pinching is performed.
	// A Power of 1 means no pinching.
	// Higher powers perform spatial pinching.
	// Lower powers un-pinch a region, moving coordinates
	// further from the center.
	// Reciprocal powers undo each other.
	Power float64
}

AxisPinch is similar to AxisSqueeze, except that it does not affect space outside of the pinched region.

Coordinates within the pinched region are pulled to the center of the region by following some polynomial.

AxisPinch can be used to prevent jagged edges on the tops and bottoms of marching cubes solids, by pinching the uneven edges into a much flatter surface.

func (*AxisPinch) Apply added in v0.2.4

func (a *AxisPinch) Apply(c model3d.Coord3D) model3d.Coord3D

Apply pinches the coordinate.

func (*AxisPinch) ApplyBounds added in v0.2.4

func (a *AxisPinch) ApplyBounds(min, max model3d.Coord3D) (newMin, newMax model3d.Coord3D)

ApplyBounds pinches the bounds.

func (*AxisPinch) Inverse added in v0.2.4

func (a *AxisPinch) Inverse() model3d.Transform

Inverse creates an AxisPinch that undoes the pinch performed by a.

type AxisSqueeze

type AxisSqueeze struct {
	// The axis to compress.
	Axis Axis

	// Bounds on the axis to compress.
	Min float64
	Max float64

	// This is (new length / old length).
	// For example, if we use a squeeze ratio of 0.1,
	// then squeezing 2 inches will bring it down to
	// 0.2 inches.
	Ratio float64
}

AxisSqueeze is a coordinate transformation which squeezes some section of space into a much smaller amount of space along some axis.

AxisSqueeze can be used to efficiently produce meshes which are mostly uniform along some axis, for example a tall cylinder.

func (*AxisSqueeze) Apply

Apply squeezes the coordinate.

func (*AxisSqueeze) ApplyBounds

func (a *AxisSqueeze) ApplyBounds(min, max model3d.Coord3D) (newMin, newMax model3d.Coord3D)

ApplyBounds squeezes the bounds.

func (*AxisSqueeze) Inverse

func (a *AxisSqueeze) Inverse() model3d.Transform

Inverse creates an AxisSqueeze that undoes the squeeze performed by a.

type Equirect

type Equirect struct {
	// contains filtered or unexported fields
}

An Equirect is an equirectangular bitmap representing colors on a sphere.

It can be used, for example, to aid in implementing a 3D polar function.

func NewEquirect

func NewEquirect(img image.Image) *Equirect

NewEquirect creates an Equirect from an image. It is assumed that the top of the image is north (positive latitude), the bottom of the image is south, the left is west (negative longitude), the right is east (positive longitude).

func (*Equirect) At

func (e *Equirect) At(g model3d.GeoCoord) color.Color

At gets the color at the given GeoCoord.

type GearProfile

type GearProfile interface {
	model2d.Solid
	PitchRadius() float64
}

func InvoluteGearProfile

func InvoluteGearProfile(pressureAngle, module, clearance float64, numTeeth int) GearProfile

InvoluteGearProfile creates a GearProfile for a standard involute gear with the given specs.

func InvoluteGearProfileSizes

func InvoluteGearProfileSizes(pressureAngle, module, addendum, dedendum float64,
	numTeeth int) GearProfile

InvoluteGearProfileSizes creates an involute gear profile using different parameters than InvoluteGearProfile.

type HelicalGear

type HelicalGear struct {
	P1      model3d.Coord3D
	P2      model3d.Coord3D
	Profile GearProfile
	Angle   float64
}

func (*HelicalGear) Contains

func (h *HelicalGear) Contains(c model3d.Coord3D) bool

func (*HelicalGear) Max

func (h *HelicalGear) Max() model3d.Coord3D

func (*HelicalGear) Min

func (h *HelicalGear) Min() model3d.Coord3D

type Ramp

type Ramp struct {
	model3d.Solid

	// P1 is the tip of the ramp, where the scale is 0.
	// Any point further in the direction of P1 will have
	// a scale of zero.
	P1 model3d.Coord3D

	// P2 is the base of the ramp, where the scale is 1.
	// Any point further in the direction of P2 will have
	// a scale of one.
	P2 model3d.Coord3D
}

A Ramp wraps an existing solid and gradually increases the scale of the solid from 0% to 100% along a given axis.

This makes it easier to make shapes like upside-down pyramids and cones for use in FDM printing without supports.

func (*Ramp) Contains

func (r *Ramp) Contains(c model3d.Coord3D) bool

type ScrewSolid

type ScrewSolid struct {
	// P1 is the center of the start of the screw.
	P1 model3d.Coord3D

	// P2 is the center of the end of the screw.
	P2 model3d.Coord3D

	// Radius is the maximum radius of the screw,
	// including grooves.
	Radius float64

	// GrooveSize is the size of the grooves.
	// This may not exceed Radius.
	GrooveSize float64

	// Pointed can be set to true to indicate that the tip
	// at the P2 end should be cut off at a 45 degree
	// angle (in the shape of a cone).
	// Can be used for internal screw holes to avoid
	// support.
	Pointed bool
}

A ScrewSolid is a model3d.Solid implementation of screws. It can also be used for screw holes, by combining it with model3d.SubtractedSolid.

Screws are similar to cylinders, so many of the fields are analogous to model3d.CylinderSolid.

func (*ScrewSolid) Contains

func (s *ScrewSolid) Contains(c model3d.Coord3D) bool

func (*ScrewSolid) Max

func (s *ScrewSolid) Max() model3d.Coord3D

func (*ScrewSolid) Min

func (s *ScrewSolid) Min() model3d.Coord3D

type SpurGear

type SpurGear struct {
	P1      model3d.Coord3D
	P2      model3d.Coord3D
	Profile GearProfile
}

func (*SpurGear) Contains

func (s *SpurGear) Contains(c model3d.Coord3D) bool

func (*SpurGear) Max

func (s *SpurGear) Max() model3d.Coord3D

func (*SpurGear) Min

func (s *SpurGear) Min() model3d.Coord3D

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL