Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added isNumber #1104

Merged
merged 1 commit into from
Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions source/geometry/FloatPoint3D.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ FloatPoint3D: cover {
x, y, z: Float
norm ::= (this x squared + this y squared + this z squared) sqrt()
azimuth ::= this y atan2(this x)
isValid ::= (this x == this x && this y == this y && this z == this z)
elevation: Float {
get {
r := this norm
if (r != 0.0f)
r = (this z / r) clamp(-1.0f, 1.0f) acos()
r
}
}
isValid ::= (this x isNumber && this y isNumber && this z isNumber)
elevation: Float { get {
r := this norm
if (r != 0.0f)
r = (this z / r) clamp(-1.0f, 1.0f) acos()
r
} }
init: func@ (=x, =y, =z)
init: func@ ~default { this init(0.0f, 0.0f, 0.0f) }
init: func@ ~fromPoint2D (point: FloatPoint2D, z := 0.0f) { this init(point x, point y, z) }
Expand Down
2 changes: 1 addition & 1 deletion source/geometry/Quaternion.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Quaternion: cover {
// z = this y
// w = this z

isValid ::= this real == this real && this imaginary isValid
isValid ::= this real isNumber && this imaginary isValid
isIdentity ::= this real equals(1.f) && this imaginary x equals(0.f) && this imaginary y equals(0.f) && this imaginary z equals(0.f)
isNull ::= this real equals(0.f) && this imaginary x equals(0.f) && this imaginary y equals(0.f) && this imaginary z equals(0.f)
norm ::= (this real squared + this imaginary norm squared) sqrt()
Expand Down
8 changes: 2 additions & 6 deletions source/sdk/lang/Numbers.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ UInt: cover from unsigned int extends ULLong {
UShort: cover from unsigned short extends ULLong

LDouble: cover from long double {
isNumber ::= this == this
toString: func -> String {
"%.2Lf" formatLDouble(this)
}
Expand Down Expand Up @@ -103,12 +104,7 @@ PtrDiff: cover from ptrdiff_t extends SSizeT

Range: cover {
min, max: Int
new: static func (.min, .max) -> This {
this: This
this min = min
this max = max
return this
}
init: func@ (=min, =max)
reduce: func (f: Func (Int, Int) -> Int) -> Int {
acc := f(min, min + 1)
for (i in min + 2 .. max) acc = f(acc, i)
Expand Down