Pose¶
Package name: jitx/pose
Location in the Kinematic Tree
The Pose
type is used to move a component, pad, shape, or
other instances within a definition's coordinate frame.
The following definitions have a default coordinate frame:
These definition types have a right-handed coordinate frame centered at (0.0, 0.0) and axis aligned with the X and Y axis.
When creating an instance in these coordinate frames we use the loc helper
function to create Pose
objects that transforms the instance's X,Y position and
rotation.
loc
syntax¶
Typical Syntax:
loc(x, y, [angle, flip-x])
loc(center, [angle, flip-x])
x, y
orcenter
is a Point defining the translation of the coordinate frame.angle
is the right-hand rotation of the coordinate frame in degrees. This parameter is optional and the default is0.0
.flip-x
is the mirroring of the coordinate frame across the Y axis. This parameter is optional and the default isfalse
.
These operations are performed in the following order:
- Flip
- Rotate
- Translate
There are several other variants of the loc
function defined below.
Translation Example¶
val p1 = Point(1.0, 5.0)
val tx = loc(1.0, 1.0)
val p2 = tx * p1
println(p2)
; Point(2.0, 6.0)
This transformation is a pure translation of the point p1
by the transform tx
Rotation Example¶
val p1 = Point(1.0, 5.0)
val tx = loc(1.0, 1.0, 90.0)
val p2 = tx * p1
println(p2)
; Point(-4.0, 2.0)
Notice that in this example - the rotation by 90 degrees is applied first, and then the point is translated by (+1.0, +1.0)
Transform Chaining¶
Transformations can be chained to form a transformation sequence:
val p1 = Point(1.0, 5.0)
val tx1 = loc(1.0, 1.0, 90.0)
val tx2 = loc(0.0, 0.0, 180.0)
val p2 = tx2 * tx1 * p1
println(p2)
; Point(4.0, -2.0)
val p3 = tx1 * tx2 * p1
println(p3)
; Point(6.0, 0.0)
Here the final operation flips the coordinate frame about the Y axis.
The order of the applied transformations is important. These transformations are not commutative.
Localization Syntax¶
The loc
function is used in concert with JITX syntax to apply the transform Pose
to a particular instance. The general form of this syntax is:
at <Pose> [on <Side>]
In this example <>
is denoting an instance of this type of object. The []
denote
optional phrases in the localization syntax.
- The
Pose
instance following theat
operator is required. - The
Side
following theon
operator is an optional phrase. can move this instance to either theTop
orBottom
side of the PCB. See Side. By default, theTop
side is used.
Example Localization Syntax¶
Example for pad instances in a pcb-landpattern
:
pcb-pad example-pad :
name = "Example Circle Pad"
type = SMD
shape = Circle(1.0)
layer(SolderMask(Top)) = Circle(1.2)
pcb-landpattern example-lp :
description = "Land Pattern Demonstrating use of 'loc' for a Pad"
pad p[1] : example-pad at loc(2.0, 3.0)
pad p[2] : example-pad at loc(2.0, 3.0) on Bottom
Example for component instances in a pcb-module
:
pcb-module example-mod :
description = "Simple Module Demonstrating Placement"
inst R1 : res-strap(10.0e3)
place(R1) at loc(0.5, 0.5) on Top
Relative-To for Component Instances¶
For pcb-module, there is a relative-to
operator for defining
placements relative to other instances. This does not apply to
pcb-landpattern
for defining pads.
Example:
pcb-module example-mod :
inst R1 : res-strap(10.0e3)
place(R1) at loc(0.5, 0.5) on Top
inst R2 : res-strap(100.0e3)
place(R2) at loc(2.0, 3.0) on Top (relative-to R1)
In this case, R2 will be placed at the location (2.5, 3.5) in the example-mod
coordinate frame.
Summary¶
Definitions¶
Pose¶
Transformation Type
public defstruct Pose <: Equalable & Hashable & HasMetaUtils :
angle: Double
center: Point
flip-x?: True|False
-
angle: Double
- Rotation of the coordinate frame in degrees. This rotation applies at the origin of the coordinate frame defined by thecenter
translate. -
center: Point
- Translation of the coordinate frame in X,Y -
flip-x?: True|False
- Mirror the coordinate frame across the Y axis. This is effectively a scaling operation that applies-1.0 * x
to the points under transformation.
Instances of this type define a coordinate transformation Typically the user would not instantiate this directly, but would instead use the loc function.
The transformation consists of 3 operations applied in order:
- Flip - Flip across the Y-Axis of the current coordinate frame.
- Rotate - Rotate around the origin of the current coordinate frame.
- Translate - Move the origin of the current coordinate frame resulting in a new coordinate frame.
Functions¶
loc¶
public defn loc (center:Point, angle:Double, flip-x?:True|False) -> Pose
- Returns
Pose
loc¶
public defn loc (center:Point, angle:Double, flip:Flip) -> Pose
- Returns
Pose
loc¶
public defn loc (center:Point, angle:Double) -> Pose
- Returns
Pose
loc¶
public defn loc (center:Point, flip:Flip) -> Pose
- Returns
Pose
loc¶
public defn loc (center:Point) -> Pose
- Returns
Pose
loc¶
public defn loc (x:Double, y:Double, angle:Double, flip:Flip) -> Pose
- Returns
Pose
loc¶
public defn loc (x:Double, y:Double, angle:Double) -> Pose
- Returns
Pose
loc¶
public defn loc (x:Double, y:Double, flip:Flip) -> Pose
- Returns
Pose
loc¶
public defn loc (x:Double, y:Double) -> Pose
- Returns
Pose
inverse¶
public defn inverse (p:Pose) -> Pose
- Returns
Pose
Pose¶
Mirroring Operations
public defn Pose (center:Point, angle:Double, flip-x?:True|False) -> Pose
- Returns
Pose
This provides a convenient method of applying flip transformations across the X axis, the Y axis, or the XY diagonal axis.
sub-angle¶
public defn sub-angle (p:Pose, angle:Double) -> Pose
- Returns
Pose
side¶
public defn side (p:Pose) -> Side
- Returns
Side
flip¶
public defn flip (p:Pose) -> Flip
- Returns
Flip
Related Packages¶
Forwarded by package: jitx