Pos

smile.modeling.Pos
See thePos companion object
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.

Attributes

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

Members list

Value members

Concrete methods

infix def *(factor: Double): Pos

Returns a Pos whose two coordinates are obtained by multiplying this one’s x and y by the given factor. For instance, (2,-3) multiplied by 10 is (20,-30). The expressions myPos * n and myPos.multiply(n) are equivalent.

Returns a Pos whose two coordinates are obtained by multiplying this one’s x and y by the given factor. For instance, (2,-3) multiplied by 10 is (20,-30). The expressions myPos * n and myPos.multiply(n) are equivalent.

Attributes

Source
Pos.scala
def *(other: Pos): Pos

Multiplies this position's x and y by the given position's x and y, respectively.

Multiplies this position's x and y by the given position's x and y, respectively.

Attributes

Source
Pos.scala
def *(other: (Double, Double)): Pos

Multiplies this position's x and y by the given pair's two numbers, respectively.

Multiplies this position's x and y by the given pair's two numbers, respectively.

Attributes

Source
Pos.scala
infix def +(another: Pos): Pos

Adds the x and y of the given Pos to the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1 + pos2, pos1.add(pos2), and pos1.offset(pos2) are equivalent.

Adds the x and y of the given Pos to the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1 + pos2, pos1.add(pos2), and pos1.offset(pos2) are equivalent.

Attributes

Source
Pos.scala
def +(other: (Double, Double)): Pos

Adds the given pair's two numbers to this position's x and y, respectively.

Adds the given pair's two numbers to this position's x and y, respectively.

Attributes

Source
Pos.scala
infix def -(another: Pos): Pos

Subtracts the x and y of the given Pos from the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1 - pos2 and pos1.subtract(pos2) are equivalent.

Subtracts the x and y of the given Pos from the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1 - pos2 and pos1.subtract(pos2) are equivalent.

Attributes

Source
Pos.scala
def -(other: (Double, Double)): Pos

Subtracts the given pair's two numbers from this position's x and y, respectively.

Subtracts the given pair's two numbers from this position's x and y, respectively.

Attributes

Source
Pos.scala
infix def /(divisor: Double): Pos

Returns a Pos whose two coordinates are obtained by dividing this one’s x and y by the given number. For instance, (20,-30) divided by 10 is (2,-3). The expressions myPos / n and myPos.divide(n) are equivalent.

Returns a Pos whose two coordinates are obtained by dividing this one’s x and y by the given number. For instance, (20,-30) divided by 10 is (2,-3). The expressions myPos / n and myPos.divide(n) are equivalent.

Attributes

Source
Pos.scala
def /(other: Pos): Pos

Divides this position's x and y by the given position's x and y, respectively.

Divides this position's x and y by the given position's x and y, respectively.

Attributes

Source
Pos.scala
def /(other: (Double, Double)): Pos

Divides this position's x and y by the given pair's two numbers, respectively.

Divides this position's x and y by the given pair's two numbers, respectively.

Attributes

Source
Pos.scala
def add(dx: Double, dy: Double): Pos

Adds the two given values to the x and y of this Pos, respectively. Returns the resulting Pos. The expressions myPos.add(dx, dy) and myPos.offset(dx, dy) are equivalent.

Adds the two given values to the x and y of this Pos, respectively. Returns the resulting Pos. The expressions myPos.add(dx, dy) and myPos.offset(dx, dy) are equivalent.

Attributes

Source
Pos.scala
def add(pos: Pos): Pos

Adds the x and y of the given Pos to the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1.add(pos2), pos1.offset(pos2), and pos1 + pos2 are equivalent.

Adds the x and y of the given Pos to the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1.add(pos2), pos1.offset(pos2), and pos1 + pos2 are equivalent.

Attributes

Source
Pos.scala
def addX(dx: Double): Pos

Returns a Pos whose x coordinate is greater than this Pos’s by the given amount.

Returns a Pos whose x coordinate is greater than this Pos’s by the given amount.

Attributes

Source
Pos.scala
def addY(dy: Double): Pos

Returns a Pos whose y coordinate is greater than this Pos’s by the given amount.

Returns a Pos whose y coordinate is greater than this Pos’s by the given amount.

Attributes

Source
Pos.scala
def centerBetween(destination: Pos): Pos

Finds the center position between this position and another.

Finds the center position between this position and another.

Attributes

Source
Pos.scala
def clamp(xMin: Double, xMax: Double, yMin: Double, yMax: Double): Pos

Returns a Pos that is as close to this Pos as possible but whose x and y are between the given lower and upper bounds (inclusive).

Returns a Pos that is as close to this Pos as possible but whose x and y are between the given lower and upper bounds (inclusive).

Value parameters

xMax

the greatest possible value of x in the resulting Pos. Must not be below xMin

xMin

the least possible value of x in the resulting Pos. Must not exceed xMax

yMax

the greatest possible value of y in the resulting Pos. Must not be below yMin

yMin

the least possible value of y in the resulting Pos. Must not exceed yMax

Attributes

See also
Source
Pos.scala
def clampX(min: Double, max: Double): Pos

Returns a Pos that is as close to this Pos as possible but whose x is between the given lower and upper bounds (inclusive).

Returns a Pos that is as close to this Pos as possible but whose x is between the given lower and upper bounds (inclusive).

Value parameters

max

the greatest possible value of x in the resulting Pos. Must not be below min

min

the least possible value of x in the resulting Pos. Must not exceed max

Attributes

See also
Source
Pos.scala
def clampY(min: Double, max: Double): Pos

Returns a Pos that is as close to this Pos as possible but whose y is between the given lower and upper bounds (inclusive).

Returns a Pos that is as close to this Pos as possible but whose y is between the given lower and upper bounds (inclusive).

Value parameters

max

the greatest possible value of y in the resulting Pos. Must not be below min

min

the least possible value of y in the resulting Pos. Must not exceed max

Attributes

See also
Source
Pos.scala

Returns a String description of the Pos. It has the form "(x,y)".

Returns a String description of the Pos. It has the form "(x,y)".

Attributes

See also
Source
Pos.scala
def directionOf(destination: Pos): Direction

Returns the smile.modeling.Direction from this Pos towards the given other Pos.

Returns the smile.modeling.Direction from this Pos towards the given other Pos.

Attributes

Source
Pos.scala
def distance(another: Pos): Double

Returns the distance between this Pos and the given Pos “as the crow flies”.

Returns the distance between this Pos and the given Pos “as the crow flies”.

Attributes

Source
Pos.scala
def divide(divisor: Double): Pos

Returns a Pos whose two coordinates are obtained by dividing this one’s x and y by the given number. For instance, (20,-30) divided by 10 is (2,-3). The expressions myPos.divide(n) and myPos / n are equivalent.

Returns a Pos whose two coordinates are obtained by dividing this one’s x and y by the given number. For instance, (20,-30) divided by 10 is (2,-3). The expressions myPos.divide(n) and myPos / n are equivalent.

Attributes

Source
Pos.scala
def moveBy(xOffset: Double, yOffset: Double): Pos

Moves this position by specified offsets. The same as smile.modeling.Pos.add with two numbers.

Moves this position by specified offsets. The same as smile.modeling.Pos.add with two numbers.

Attributes

Source
Pos.scala
def multiply(factor: Double): Pos

Returns a Pos whose two coordinates are obtained by multiplying this one’s x and y by the given factor. For instance, (2,-3) multiplied by 10 is (20,-30). The expressions myPos.multiply(n) and myPos * n are equivalent.

Returns a Pos whose two coordinates are obtained by multiplying this one’s x and y by the given factor. For instance, (2,-3) multiplied by 10 is (20,-30). The expressions myPos.multiply(n) and myPos * n are equivalent.

Attributes

Source
Pos.scala
def nextPos(velocity: Velocity): Pos

Returns the Pos that an object moving at the given velocity reaches in one unit of time. That is, adds the dx and dy components of the given velocity to this Pos and returns the result.

Returns the Pos that an object moving at the given velocity reaches in one unit of time. That is, adds the dx and dy components of the given velocity to this Pos and returns the result.

Attributes

Source
Pos.scala

Returns a Pos that is as close to this Pos as possible but has an x coordinate equal to or greater than the given limit.

Returns a Pos that is as close to this Pos as possible but has an x coordinate equal to or greater than the given limit.

Attributes

See also
Source
Pos.scala

Returns a Pos that is as close to this Pos as possible but has an x coordinate less than or equal to the given limit.

Returns a Pos that is as close to this Pos as possible but has an x coordinate less than or equal to the given limit.

Attributes

See also
Source
Pos.scala
def noHigherThan(yMin: Double): Pos

Returns a Pos that is as close to this Pos as possible but has a y coordinate equal to or greater than the given limit.

Returns a Pos that is as close to this Pos as possible but has a y coordinate equal to or greater than the given limit.

Attributes

See also
Source
Pos.scala
def noLowerThan(yMax: Double): Pos

Returns a Pos that is as close to this Pos as possible but has a y coordinate less than or equal to the given limit.

Returns a Pos that is as close to this Pos as possible but has a y coordinate less than or equal to the given limit.

Attributes

See also
Source
Pos.scala
def offset(dx: Double, dy: Double): Pos

Returns the Pos that is dx and dy removed from this Pos. The expressions myPos.offset(dx, dy) and myPos.add(dx, dy) are equivalent.

Returns the Pos that is dx and dy removed from this Pos. The expressions myPos.offset(dx, dy) and myPos.add(dx, dy) are equivalent.

Attributes

Source
Pos.scala
def offset(another: Pos): Pos

Returns the Pos that is removed from this Pos by the amount indicated by the given Pos. The expressions pos1.offset(pos2), pos1.add(pos2), and pos1 + pos2 are equivalent.

Returns the Pos that is removed from this Pos by the amount indicated by the given Pos. The expressions pos1.offset(pos2), pos1.add(pos2), and pos1 + pos2 are equivalent.

Attributes

Source
Pos.scala
def rotateAround(angle: Double, centerOfRotation: Pos): Pos

Rotates the position around a specified center of rotation by a given angle in degrees. Right angles (multiples of 90 degrees) are computed exactly.

Rotates the position around a specified center of rotation by a given angle in degrees. Right angles (multiples of 90 degrees) are computed exactly.

Value parameters

angle

The angle in degrees to rotate the position by. Positive angles rotate counterclockwise as seen on screen, where the y axis points down. Pos(1, 0) turns toward Pos(0, -1), as smile.modeling.Direction's angles do.

Attributes

Source
Pos.scala

Rotates the position around the origin (0,0) by a specified angle in degrees. Right angles (multiples of 90 degrees) are computed exactly.

Rotates the position around the origin (0,0) by a specified angle in degrees. Right angles (multiples of 90 degrees) are computed exactly.

Value parameters

angle

The angle in degrees to rotate the position by. Positive angles rotate counterclockwise as seen on screen, where the y axis points down. Pos(1, 0) turns toward Pos(0, -1), as smile.modeling.Direction's angles do.

Attributes

Source
Pos.scala

Returns a String description of the Pos that is identical to toString except it has two decimals for each coordinate.

Returns a String description of the Pos that is identical to toString except it has two decimals for each coordinate.

Attributes

Source
Pos.scala
def scaleBy(horizontalFactor: Double, verticalFactor: Double, relativityPoint: Pos): Pos

Scales this position's horizontal and vertical distance from relativityPoint by the given factors.

Scales this position's horizontal and vertical distance from relativityPoint by the given factors.

Attributes

Source
Pos.scala
def scaleByRelativeToOrigin(horizontalFactor: Double, verticalFactor: Double): Pos

Scales the position relative to the origin (0,0) by specified horizontal and vertical factors.

Scales the position relative to the origin (0,0) by specified horizontal and vertical factors.

Attributes

Source
Pos.scala
def setX(newX: Double): Pos

Returns a Pos whose x equals the given value and whose y equals this Pos’s y.

Returns a Pos whose x equals the given value and whose y equals this Pos’s y.

Attributes

Source
Pos.scala
def setY(newY: Double): Pos

Returns a Pos whose x equals this Pos’s x and whose y equals the given value.

Returns a Pos whose x equals this Pos’s x and whose y equals the given value.

Attributes

Source
Pos.scala
def subtract(another: Pos): Pos

Subtracts the x and y of the given Pos from the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1.subtract(pos2) and pos1 - pos2 are equivalent.

Subtracts the x and y of the given Pos from the x and y of this Pos, respectively. Returns the resulting Pos. The expressions pos1.subtract(pos2) and pos1 - pos2 are equivalent.

Attributes

Source
Pos.scala
def subtract(dx: Double, dy: Double): Pos

Subtracts the two given values from the x and y of this Pos, respectively. Returns the resulting Pos.

Subtracts the two given values from the x and y of this Pos, respectively. Returns the resulting Pos.

Attributes

Source
Pos.scala
def subtractX(dx: Double): Pos

Returns a Pos whose x coordinate is less than this Pos’s by the given amount.

Returns a Pos whose x coordinate is less than this Pos’s by the given amount.

Attributes

Source
Pos.scala
def subtractY(dy: Double): Pos

Returns a Pos whose y coordinate is less than this Pos’s by the given amount.

Returns a Pos whose y coordinate is less than this Pos’s by the given amount.

Attributes

Source
Pos.scala
def toPair: (Double, Double)

Returns the x and y coordinates of the Pos as a tuple.

Returns the x and y coordinates of the Pos as a tuple.

Attributes

Source
Pos.scala
override def toString: String

Returns a String description of the Pos. It has the form "(x,y)". This is equivalent to smile.modeling.Pos.description.

Returns a String description of the Pos. It has the form "(x,y)". This is equivalent to smile.modeling.Pos.description.

Attributes

See also
Definition Classes
Any
Source
Pos.scala
def turnInto[Result](f: (Double, Double) => Result): Result

Applies the given function to the two coordinates of the Pos and returns the result.

Applies the given function to the two coordinates of the Pos and returns the result.

Attributes

Source
Pos.scala
def unary_-: Pos

Returns the Pos that is the opposite of this Pos. For instance, the opposite of (2,-3) is (-2,3).

Returns the Pos that is the opposite of this Pos. For instance, the opposite of (2,-3) is (-2,3).

Attributes

Source
Pos.scala
def vectorTo(destination: Pos): Pos

Returns a Pos whose x and y capture the relative distance from this Pos towards the given Pos. That is, subtracts the x and y of this from the x and y of the given Pos, respectively. The expressions pos1.vectorTo(pos2) and pos2 - pos1 are equivalent.

Returns a Pos whose x and y capture the relative distance from this Pos towards the given Pos. That is, subtracts the x and y of this from the x and y of the given Pos, respectively. The expressions pos1.vectorTo(pos2) and pos2 - pos1 are equivalent.

Attributes

Source
Pos.scala
def withX(computeNew: Double => Double): Pos

Returns a Pos whose x is determined by applying the given function to the x of this Pos and whose y equals that of this Pos.

Returns a Pos whose x is determined by applying the given function to the x of this Pos and whose y equals that of this Pos.

Attributes

Source
Pos.scala
def withXY(computeNew: (Double, Double) => (Double, Double)): Pos

Returns a Pos whose x and y are determined by applying the given function to the x and y of this Pos.

Returns a Pos whose x and y are determined by applying the given function to the x and y of this Pos.

Attributes

Source
Pos.scala
def withY(computeNew: Double => Double): Pos

Returns a Pos whose x equals that of this Pos and whose y is determined by applying the given function to the y of this Pos.

Returns a Pos whose x equals that of this Pos and whose y is determined by applying the given function to the y of this Pos.

Attributes

Source
Pos.scala
def xDiff(another: Pos): Double

Returns the difference between this Pos’s x coordinate and the given one’s.

Returns the difference between this Pos’s x coordinate and the given one’s.

Attributes

Returns

the difference, which is positive if the given Pos’s x is greater than this one’s and negative if the reverse is true

Source
Pos.scala
def yDiff(another: Pos): Double

Returns the difference between this Pos’s y coordinate and the given one’s.

Returns the difference between this Pos’s y coordinate and the given one’s.

Attributes

Returns

the difference, which is positive if the given Pos’s y is greater than this one’s and negative if the reverse is true

Source
Pos.scala

Inherited methods

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala