在C#中的3D向量数组中查找最短向量

时间:2019-12-25 06:37:45

标签: c#

我有以下代码:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.locationtracker2019"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    androidx.cardview.widget.CardView
    implementation 'androidx.recyclerview:recyclerview:1.0.0'

    implementation "com.google.firebase:firebase-database:10.2.0"
    implementation "com.google.firebase:firebase-auth:10.2.0"
    implementation "com.firebaseui:firebase-ui-auth:1.2.0"
    implementation "com.firebaseui:firebase-ui-database:1.2.0"


    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

我想要功能FindShortest接受3D向量数组并返回最短的向量。每个向量都显示为包含3个元素(x,y和z)的数组。如果多个向量具有相同的长度,则该函数应返回其中任何一个。

要确定向量的长度,我使用以下公式:Math.sqrt x ^ 2 + y ^ 2 + z ^ 2

有人可以帮我吗?

0 个答案:

没有答案