final case class Pos(x: Double, y: Double) extends Product with Serializable
Each instance of this class represents a location on a two-dimensional plane. A Pos object is
essentially a pair of two coordinates, x and y. Pos objects are immutable.
This class has an alias in the top-level package o1, so it’s accessible to students simply
via import o1._.
- x
the x coordinate of the
Pos- y
the y coordinate of the
Pos
- Alphabetic
- By Inheritance
- Pos
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Pos(x: Double, y: Double)
- x
the x coordinate of the
Pos- y
the y coordinate of the
Pos
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def *(factor: Double): Pos
Returns a
Poswhose two coordinates are obtained by multiplying this one’sxandyby the given factor.Returns a
Poswhose two coordinates are obtained by multiplying this one’sxandyby the given factor. For instance, (2,-3) multiplied by 10 is (20,-30). The expressionsmyPos * nandmyPos.multiply(n)are equivalent.- Annotations
- @inline()
- def +(another: Pos): Pos
Adds the
xandyof the givenPosto thexandyof thisPos, respectively.Adds the
xandyof the givenPosto thexandyof thisPos, respectively. Returns the resultingPos. The expressionspos1 + pos2,pos1.add(pos2), andpos1.offset(pos2)are equivalent.- Annotations
- @inline()
- def -(another: Pos): Pos
Subtracts the
xandyof the givenPosfrom thexandyof thisPos, respectively.Subtracts the
xandyof the givenPosfrom thexandyof thisPos, respectively. Returns the resultingPos. The expressionspos1 - pos2andpos1.subtract(pos2)are equivalent.- Annotations
- @inline()
- def /(divisor: Double): Pos
Returns a
Poswhose two coordinates are obtained by dividing this one’sxandyby the given number.Returns a
Poswhose two coordinates are obtained by dividing this one’sxandyby the given number. For instance, (20,-30) divided by 10 is (2,-3). The expressionsmyPos / nandmyPos.divide(n)are equivalent.- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def add(pos: Pos): Pos
Adds the
xandyof the givenPosto thexandyof thisPos, respectively.Adds the
xandyof the givenPosto thexandyof thisPos, respectively. Returns the resultingPos. The expressionspos1.add(pos2),pos1.offset(pos2), andpos1 + pos2are equivalent.- Annotations
- @inline()
- def add(dx: Double, dy: Double): Pos
Adds the two given values to the
xandyof thisPos, respectively.Adds the two given values to the
xandyof thisPos, respectively. Returns the resultingPos. The expressionsmyPosadd(dx, dy)andmyPosoffset(dx, dy)are equivalent.- Annotations
- @inline()
- def addX(dx: Double): Pos
Returns a
Poswhosexcoordinate is greater than thisPos’s by the given amount.Returns a
Poswhosexcoordinate is greater than thisPos’s by the given amount.- Annotations
- @inline()
- def addY(dy: Double): Pos
Returns a
Poswhoseycoordinate is greater than thisPos’s by the given amount.Returns a
Poswhoseycoordinate is greater than thisPos’s by the given amount.- Annotations
- @inline()
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clamp(xMin: Double, xMax: Double, yMin: Double, yMax: Double): Pos
Returns a
Posthat is as close to thisPosas possible but whosexandyare between the given lower and upper bounds (inclusive).Returns a
Posthat is as close to thisPosas possible but whosexandyare between the given lower and upper bounds (inclusive).- xMin
the least possible value of
xin the resultingPos; must not exceedxMax- xMax
the greatest possible value of
xin the resultingPos; must not be belowxMin- yMin
the least possible value of
yin the resultingPos; must not exceedyMax- yMax
the greatest possible value of
yin the resultingPos; must not be belowyMin
- Annotations
- @inline()
- See also
noLowerThan, noHigherThan, noFurtherLeftThan, noFurtherRightThan, clampX, clampY
- def clampX(min: Double, max: Double): Pos
Returns a
Posthat is as close to thisPosas possible but whosexis between the given lower and upper bounds (inclusive).Returns a
Posthat is as close to thisPosas possible but whosexis between the given lower and upper bounds (inclusive).- min
the least possible value of
xin the resultingPos; must not exceedmax- max
the greatest possible value of
xin the resultingPos; must not be belowmin
- Annotations
- @inline()
- See also
- def clampY(min: Double, max: Double): Pos
Returns a
Posthat is as close to thisPosas possible but whoseyis between the given lower and upper bounds (inclusive).Returns a
Posthat is as close to thisPosas possible but whoseyis between the given lower and upper bounds (inclusive).- min
the least possible value of
yin the resultingPos; must not exceedmax- max
the greatest possible value of
yin the resultingPos; must not be belowmin
- Annotations
- @inline()
- See also
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def directionOf(destination: Pos): Direction
Returns the Direction from this
Postowards the given otherPos.Returns the Direction from this
Postowards the given otherPos.- Annotations
- @inline()
- def distance(another: Pos): Double
Returns the distance between this
Posand the givenPos“as the crow flies”.Returns the distance between this
Posand the givenPos“as the crow flies”.- Annotations
- @inline()
- def divide(divisor: Double): Pos
Returns a
Poswhose two coordinates are obtained by dividing this one’sxandyby the given number.Returns a
Poswhose two coordinates are obtained by dividing this one’sxandyby the given number. For instance, (20,-30) divided by 10 is (2,-3). The expressionsmyPos.divide(n)andmyPos / nare equivalent.- Annotations
- @inline()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def multiply(factor: Double): Pos
Returns a
Poswhose two coordinates are obtained by multiplying this one’sxandyby the given factor.Returns a
Poswhose two coordinates are obtained by multiplying this one’sxandyby the given factor. For instance, (2,-3) multiplied by 10 is (20,-30). The expressionsmyPos.multiply(n)andmyPos * nare equivalent.- Annotations
- @inline()
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def nextPos(velocity: Velocity): Pos
Returns the
Posthat an object moving at the given velocity reaches in one unit of time.Returns the
Posthat an object moving at the given velocity reaches in one unit of time. That is, adds thedxanddycomponents of the given velocity to thisPosand returns the result.- Annotations
- @inline()
- def noFurtherLeftThan(xMin: Double): Pos
Returns a
Posthat is as close to thisPosas possible but has axcoordinate equal to or greater than the given limit.Returns a
Posthat is as close to thisPosas possible but has axcoordinate equal to or greater than the given limit.- Annotations
- @inline()
- See also
- def noFurtherRightThan(xMax: Double): Pos
Returns a
Posthat is as close to thisPosas possible but has aycoordinate less than or equal to the given limit.Returns a
Posthat is as close to thisPosas possible but has aycoordinate less than or equal to the given limit.- Annotations
- @inline()
- See also
- def noHigherThan(yMin: Double): Pos
Returns a
Posthat is as close to thisPosas possible but has aycoordinate equal to or greater than the given limit.Returns a
Posthat is as close to thisPosas possible but has aycoordinate equal to or greater than the given limit.- Annotations
- @inline()
- See also
- def noLowerThan(yMax: Double): Pos
Returns a
Posthat is as close to thisPosas possible but has aycoordinate less than or equal to the given limit.Returns a
Posthat is as close to thisPosas possible but has aycoordinate less than or equal to the given limit.- Annotations
- @inline()
- See also
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def offset(another: Pos): Pos
Returns the
Posthat is removed from thisPosby the amount indicated by the givenPos.Returns the
Posthat is removed from thisPosby the amount indicated by the givenPos. The expressionspos1.offset(pos2),pos1.add(pos2), andpos1 + pos2are equivalent.- Annotations
- @inline()
- def offset(dx: Double, dy: Double): Pos
Returns the
Posthat isdxanddyremoved from thisPos.Returns the
Posthat isdxanddyremoved from thisPos. The expressionsmyPosoffset(dx, dy)andmyPosadd(dx, dy)are equivalent.- Annotations
- @inline()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def roughly: String
Returns a
Stringdescription of thePosthat is identical to toString except it has two decimals for each coordinate.Returns a
Stringdescription of thePosthat is identical to toString except it has two decimals for each coordinate.- Annotations
- @inline()
- def setX(newX: Double): Pos
Returns a
Poswhosexequals the given value and whoseyequals thisPos’sy.Returns a
Poswhosexequals the given value and whoseyequals thisPos’sy.- Annotations
- @inline()
- def setY(newY: Double): Pos
Returns a
Poswhosexequals thisPos’sxand whoseyequals the given value.Returns a
Poswhosexequals thisPos’sxand whoseyequals the given value.- Annotations
- @inline()
- def subtract(another: Pos): Pos
Subtracts the
xandyof the givenPosfrom thexandyof thisPos, respectively.Subtracts the
xandyof the givenPosfrom thexandyof thisPos, respectively. Returns the resultingPos. The expressionspos1.subtract(pos2)andpos1 - pos2are equivalent.- Annotations
- @inline()
- def subtractX(dx: Double): Pos
Returns a
Poswhosexcoordinate is less than thisPos’s by the given amount.Returns a
Poswhosexcoordinate is less than thisPos’s by the given amount.- Annotations
- @inline()
- def subtractY(dy: Double): Pos
Returns a
Poswhoseycoordinate is less than thisPos’s by the given amount.Returns a
Poswhoseycoordinate is less than thisPos’s by the given amount.- Annotations
- @inline()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toPair: (Double, Double)
Returns the
xandycoordinates of thePosas a tuple.Returns the
xandycoordinates of thePosas a tuple.- Annotations
- @inline()
- def toString: String
Returns a
Stringdescription of thePos. - def turnInto[Result](f: (Double, Double) => Result): Result
Applies the given function to the two coordinates of the
Posand returns the result.Applies the given function to the two coordinates of the
Posand returns the result.- Annotations
- @inline()
- def unary_-: Pos
Returns the
Posthat is the opposite of thisPos.Returns the
Posthat is the opposite of thisPos. For instance, the opposite of (2,-3) is (-2,3).- Annotations
- @inline()
- def vectorTo(destination: Pos): Pos
Returns a
Posthosexandycapture the relative distance from thisPostowards the givenPos.Returns a
Posthosexandycapture the relative distance from thisPostowards the givenPos. That is, subtracts thexandyof the thisPosfrom thexandyof givenPos, respectively. The expressionspos1.vectorTo(pos2)andpos2 - pos1are equivalent.- Annotations
- @inline()
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withX(computeNew: (Double) => Double): Pos
Returns a
Poswhosexis determined by applying the given function to thexof thisPosand whoseyequals that of thisPos.Returns a
Poswhosexis determined by applying the given function to thexof thisPosand whoseyequals that of thisPos.- computeNew
a function that takes in an x coordinate and returns the x for the resulting
Pos
- Annotations
- @inline()
- def withXY(computeNew: (Double, Double) => (Double, Double)): Pos
Returns a
Poswhosexandyare determined by applying the given function to thexandyof thisPos.Returns a
Poswhosexandyare determined by applying the given function to thexandyof thisPos.- computeNew
a function that takes in an x and a y and returns a pair that contains the coordinates of the resulting
Pos
- Annotations
- @inline()
- def withY(computeNew: (Double) => Double): Pos
Returns a
Poswhosexequals that of thisPosand whoseyis determined by applying the given function to theyof thisPos.Returns a
Poswhosexequals that of thisPosand whoseyis determined by applying the given function to theyof thisPos.- computeNew
a function that takes in a y coordinate and returns the y for the resulting
Pos
- Annotations
- @inline()
- val x: Double
- def xDiff(another: Pos): Double
Returns the difference between this
Pos’sxcoordinate and the given one’s.Returns the difference between this
Pos’sxcoordinate and the given one’s.- returns
the difference, which is positive if the given
Pos’sxis greater than this one’s and negative if the reverse is true
- Annotations
- @inline()
- val y: Double
- def yDiff(another: Pos): Double
Returns the difference between this
Pos’sycoordinate and the given one’s.Returns the difference between this
Pos’sycoordinate and the given one’s.- returns
the difference, which is positive if the given
Pos’syis greater than this one’s and negative if the reverse is true
- Annotations
- @inline()
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.