viz

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BHC = 0.2 //Barnes-Hut Constant
)
View Source
const FK = 1e-4
View Source
const FMAX = 10.0
View Source
const GMAX = 30.0
View Source
const (
	// number of iterations to use for force layout
	Iters = 500
)
View Source
const W = 1.0

Variables

This section is empty.

Functions

func NetSvg

func NetSvg(name string, net *xir.Net) error

Create an SVG image

func SvgDrawLinks(net *xir.Net, cx, cy int, canvas *svg.SVG)

Draw the links of an xir network on the provided svg canvas relative to the central point (cx, cy)

func SvgDrawNodes

func SvgDrawNodes(net *xir.Net, cx, cy int, canvas *svg.SVG)

Draw the nodes of an xir network on the provided svg canvas relative to the central point (cx, cy)

func Vtag

func Vtag(net *xir.Net)

Types

type Bounds

type Bounds struct {
	Width, Height float64
}

Simple data structure to keep track of the size of things

type Pinode

type Pinode struct {
	Quad     [4]Pnode  // The four quadrants this interior node presides over
	Centroid xir.Point // Center of mass for this interior node

	Width float64 // The collective width of the underlying 4 quadrants
	Mass  float64 // The collective mass of the underlying 4 quadrants
	// contains filtered or unexported fields
}

func PTree

func PTree(net *xir.Net) *Pinode

PTree constructs a new PTree from an xir network. The return value is the root of the tree. This is an O(n*log(n)) operation where n is the number of nodes in the provided network.

func (*Pinode) Bounds

func (ptr *Pinode) Bounds() Bounds

Compute the height and width bounds for this internal node

func (*Pinode) Force

func (ptr *Pinode) Force(node Positional)

Compute the force on the specified node within this Pinode

func (*Pinode) Forces

func (ptr *Pinode) Forces(net *xir.Net)

Compute the forces on all nodes in the network within this Pinode

func (*Pinode) Height

func (ptr *Pinode) Height() int

Compute the height of this interior node

func (*Pinode) Insert

func (pi *Pinode) Insert(x *Plnode)

This method inserts a new Pleaf node below this Pinode. This is a recursive insertion with O(log(n)) complexity where n is the number of nodes currently below this Pinode.

func (*Pinode) Limit

func (ptr *Pinode) Limit(quad int) *xir.Point

Compute the extreme corner value of a given quadrant

func (*Pinode) NewQuad

func (p *Pinode) NewQuad(sector int) *Pinode

This method creates a new quad for the specified sector of this Pinode.

func (*Pinode) Position

func (p *Pinode) Position() *xir.Point

Implementation of the Positional interface for interior nodes

func (*Pinode) RecomputeCentroid

func (p *Pinode) RecomputeCentroid()

func (*Pinode) Select

func (p *Pinode) Select(x *Plnode) int

This method determines which quadrant a new leaf node node should fall in.

func (*Pinode) Size

func (ptr *Pinode) Size() int

Compute the total number of leaf nodes presiding within this Pinode

func (*Pinode) Velocity

func (p *Pinode) Velocity() *xir.Point

func (*Pinode) Weight

func (p *Pinode) Weight() float64

type Plnode

type Plnode struct {
	Data Positional // The data that is encapsulated by this leaf node
}

type Pnode

type Pnode interface{}

A Pnode is a generic node type that is always either a Pinode or Plnode

type Positional

type Positional interface {
	Position() *xir.Point
	Velocity() *xir.Point
	Weight() float64
}

The positional interface must be implemented by data that is laied out and presented by this code

type RectBounds

type RectBounds struct {
	L, R, T, B float64
}

func (*RectBounds) Height

func (r *RectBounds) Height() float64

func (*RectBounds) Width

func (r *RectBounds) Width() float64

Jump to

Keyboard shortcuts

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