Code Sketch


Batman Equation and Curve
By: Anay Narendra Kamat
cleari()

setSpeed(superFast)


// Bottom Curves
plot { (x,y) =>
    val value = 3*Math.sqrt(4 - (Math.abs(x)-2)~^2) + Math.abs(x) - 20 -4*y
    
    (!value.isNaN && value >= 0 & value < 0.7  )
}

// Curves Next to bottom Curves
plot { (x,y) =>
    val value = 3*Math.sqrt(4 - (Math.abs(x)-6)~^2) + Math.abs(x) - 20 -4*y
    
    (!value.isNaN && value >= 0 & value < 0.7  )
}

// Side curves
plot { (x,y) =>

    val twoYMinusOne = Math.abs(2*y - 1)
    val sevenMinusTwoYMinusOne = 7 - twoYMinusOne
    val requiredSquareRoot = Math.sqrt(Math.abs(sevenMinusTwoYMinusOne) / sevenMinusTwoYMinusOne)
        
    val value = x~^2 + 4*y~^2 - 100*requiredSquareRoot
    
    (!value.isNaN && value >= 0 & value < 0.8  )
}

// top curves
plot { (x,y) =>

    val xMinusFour = Math.abs(Math.abs(x) - 4)
    val twoMinusXMinusFour = 2 - xMinusFour
    val requiredSquareRoot = Math.sqrt(Math.abs(twoMinusXMinusFour) / twoMinusXMinusFour)
        
    val value = 2*(Math.abs(x)-3)~^2 -9*y + 18*requiredSquareRoot
    
    (!value.isNaN && value >= 0 & value < 0.8  )
}

// Ears
plot { (x,y) =>

    val oneThirtySixXMinus229 = Math.abs( 136*Math.abs(x) - 229 )
    val fortyThreeMinusOneThirtySixXMinus229 = 43 - oneThirtySixXMinus229
    val requiredSquareRoot = Math.sqrt(Math.abs(fortyThreeMinusOneThirtySixXMinus229) / fortyThreeMinusOneThirtySixXMinus229)
        
    val value = -68*Math.abs(Math.abs(x) - 3.0/2) - 9*y + 54*requiredSquareRoot
    
    (!value.isNaN && value.toLong == 0  )
}

// Head line
plot { (x,y) =>

    val numerator = 1.3677 - Math.abs(x)
    val requiredSquareRoot = Math.sqrt(Math.abs(numerator) / numerator)
        
    val value = y - 5*requiredSquareRoot
    
    (!value.isNaN && value >= 0 & value < 0.01  )
}



def SCALE_FACTOR = 30

def plot(checker:(Double, Double) => Boolean) = for {
    theX <- (-10*SCALE_FACTOR to 10*SCALE_FACTOR)
    theY <- (-10*SCALE_FACTOR to 10*SCALE_FACTOR)

    val x = theX.toDouble / SCALE_FACTOR
    val y = theY.toDouble / SCALE_FACTOR

    if checker(x,y)
    
} yield {
    jumpTo(theX, theY)
    dot(2)
}

implicit class FixPow(x: Double) { def ~^(p: Double): Double = Math.pow(x, p) }