All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.unibo.alchemist.model.environments.Euclidean2DEnvironment.kt Maven / Gradle / Ivy

There is a newer version: 35.0.3
Show newest version
/*
 * Copyright (C) 2010-2023, Danilo Pianini and contributors
 * listed, for each module, in the respective subproject's build.gradle.kts file.
 *
 * This file is part of Alchemist, and is distributed under the terms of the
 * GNU General Public License, with a linking exception,
 * as described in the file LICENSE in the Alchemist distribution's top directory.
 */

package it.unibo.alchemist.model.environments

import it.unibo.alchemist.model.EuclideanEnvironment
import it.unibo.alchemist.model.positions.Euclidean2DPosition

/**
 * A bidimensional Euclidean space with any concentration type [T].
 */
interface Euclidean2DEnvironment : EuclideanEnvironment {

    override val origin: Euclidean2DPosition get() = Companion.origin

    /**
     * Creates a new [Euclidean2DPosition].
     */
    fun makePosition(x: Double, y: Double): Euclidean2DPosition = Euclidean2DPosition(x, y)

    /**
     * Creates a new [Euclidean2DPosition].
     */
    override fun makePosition(vararg coordinates: Double): Euclidean2DPosition {
        require(coordinates.size == 2) { "Illegal coordinates (required 2): ${coordinates.contentToString()}" }
        return makePosition(coordinates[0], coordinates[1])
    }

    override fun makePosition(vararg coordinates: Number): Euclidean2DPosition {
        require(coordinates.size == 2) { "Illegal coordinates (required 2): ${coordinates.contentToString()}" }
        return makePosition(coordinates[0].toDouble(), coordinates[1].toDouble())
    }

    companion object {
        /**
         * The origin of this Euclidean environment: vector [0, 0].
         */
        val origin = Euclidean2DPosition(0.0, 0.0)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy