smile.modeling

package smile.modeling

Members list

Type members

Classlikes

final case class Affine

An affine map of the plane, with its coefficients in the order a canvas, Java2D and SVG all take them. (x, y) goes to (a * x + c * y + e, b * x + d * y + f). That makes it setTransform(a, b, c, d, e, f) on a canvas, new AffineTransform(a, b, c, d, e, f) in Java2D and matrix(a b c d e f) in SVG.

An affine map of the plane, with its coefficients in the order a canvas, Java2D and SVG all take them. (x, y) goes to (a * x + c * y + e, b * x + d * y + f). That makes it setTransform(a, b, c, d, e, f) on a canvas, new AffineTransform(a, b, c, d, e, f) in Java2D and matrix(a b c d e f) in SVG.

Every affine is normalized when it is made, so that equal maps are equal values. Linear coefficients within smile.modeling.Affine.Tolerance times the largest of a to d of 0, 1 or -1 become exactly that, e and f are rounded to the nearest multiple of 2^-20, and -0.0 becomes 0.0. Equality is exact over the normalized values.

A public affine is always invertible and finite.

Attributes

Companion
object
Source
Affine.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Affine

Attributes

Companion
class
Source
Affine.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Affine.type
object Align

The Align singleton provides tools for describing the horizontal and vertical alignment of graphical elements.

The Align singleton provides tools for describing the horizontal and vertical alignment of graphical elements.

Attributes

Source
Align.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Align.type
final case class Bounds(upperLeftCorner: Pos, lowerRightCorner: Pos)

Represents the boundaries of a rectangular area, defined by its upper left and lower right corners.

Represents the boundaries of a rectangular area, defined by its upper left and lower right corners.

Attributes

Companion
object
Source
Bounds.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Bounds

Provides factory methods for creating Bounds objects, which represent rectangular areas in a coordinate space.

Provides factory methods for creating Bounds objects, which represent rectangular areas in a coordinate space.

Attributes

Companion
class
Source
Bounds.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Bounds.type
final case class Direction

Each instance of this class represents a direction on a two-dimensional plane. A direction consists of two components: dx and dy, each of which is a number between -1.0 and +1.0 (inclusive). dx indicates the degree to which the x coordinate changes when moving in that direction. dy is the same for the y coordinate. The x coordinate increases rightwards and y downwards.

Each instance of this class represents a direction on a two-dimensional plane. A direction consists of two components: dx and dy, each of which is a number between -1.0 and +1.0 (inclusive). dx indicates the degree to which the x coordinate changes when moving in that direction. dy is the same for the y coordinate. The x coordinate increases rightwards and y downwards.

For example, moving straight rightwards can be thought of as moving in a Direction with a dx of +1.0 and a dy of 0.0. The upward direction has a dx of 0.0 and a dy of -1.0. Diagonals have non-zero values for both dx and dy.

The squares of the dx and dy of any Direction always sum to roughly 1.0, except for the special value NoDirection, which represents the lack of a direction and has zero for both components. A Direction differs from a smile.modeling.Velocity, which combines a direction of movement and a speed.

You don’t instantiate Direction directly. You create Directions with the methods on this class’s companion object. Among other things, you can:

  • construct a direction from two differences between coordinates, as in Direction.fromDeltas(-100, 50), or
  • create a direction that corresponds to a given angle, as in Direction.fromDegrees(60) and Direction.fromRadians(-scala.math.Pi / 4).

Some of the methods of a Direction object also create and return new Directions, as does the directionOf method on Pos objects. Moreover, this class’s companion object has a few predefined Direction constants: Up, Down, Left, Right, and NoDirection.

Direction objects are immutable.

Attributes

Companion
object
Source
Direction.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Direction

This companion object of class `Direction` provides some constants of type Direction and methods for creating new Direction instances.

This companion object of class `Direction` provides some constants of type Direction and methods for creating new Direction instances.

Attributes

Companion
class
Source
Direction.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Direction.type
object Pos

This companion object of class `Pos` provides alternative methods for creating new Pos objects.

This companion object of class `Pos` provides alternative methods for creating new Pos objects.

On the JVM, smile.modeling adds Pos(point) for a java.awt.Point as an extension on this object. import smile.modeling.* brings it into scope.

Attributes

Companion
class
Source
Pos.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Pos.type
final case class Pos(x: Double, y: Double)

Each instance of this class represents a location on a two-dimensional plane. A Pos object is a pair of two coordinates, x and y. Pos objects are immutable.

Each instance of this class represents a location on a two-dimensional plane. A Pos object is a pair of two coordinates, x and y. Pos objects are immutable.

Attributes

Companion
object
Source
Pos.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Enumerates the types of positions used in positioning and aligning elements within a graphical context.

Enumerates the types of positions used in positioning and aligning elements within a graphical context.

Attributes

Source
PositionType.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
enum Side

Enum representing the four cardinal sides.

Enum representing the four cardinal sides.

Attributes

Source
Side.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Velocity(direction: Direction, speed: Double)

Each instance of this class represents movement in the context of a two-dimensional plane. A velocity is a combination of a smile.modeling.Direction of movement with a speed (a non-negative Double).

Each instance of this class represents movement in the context of a two-dimensional plane. A velocity is a combination of a smile.modeling.Direction of movement with a speed (a non-negative Double).

Another way to think about a Velocity is to divide it in two components: dx and dy. dx indicates the amount (and direction) of movement along the x-axis. dy is the same for the y-axis. The x coordinate increases rightwards and y downwards. For instance, a velocity with a dx of 10 and a dy of zero indicates rightward movement, and a velocity with a dx of -100 and a dy of -100 indicates faster movement leftwards and upwards.

There are many ways to create a Velocity using the methods on the companion object. Among other things, you can:

  • construct a velocity from a direction and a (positive or zero) speed, as in Velocity(Direction.Left, 50),
  • construct a velocity from dx and dy, as in Velocity(-100, 50), or
  • determine the velocity needed to go from one smile.modeling.Pos to another in a single unit of time, as in Velocity.between(pos1, pos2).

Many of the methods on Velocity objects also create and return new velocities.

Velocity objects are immutable.

Value parameters

speed

the speed of movement, which cannot be negative

Attributes

Companion
object
Source
Velocity.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Velocity

This companion object of class `Velocity` exists primarily to provide convenience methods for creating new instances of Velocity.

This companion object of class `Velocity` exists primarily to provide convenience methods for creating new instances of Velocity.

Attributes

Companion
class
Source
Velocity.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Velocity.type

Extensions

Extensions

extension (companion: Pos.type)
def apply(point: Point): Pos

Constructs a smile.modeling.Pos instance from the coordinates of the given Point object. JVM only.

Constructs a smile.modeling.Pos instance from the coordinates of the given Point object. JVM only.

Attributes

Source
JVMPosConversions.scala