Skip to content

Commit

Permalink
add angle3D
Browse files Browse the repository at this point in the history
  • Loading branch information
berberman committed Oct 22, 2019
1 parent 5e6b456 commit 321373a
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 95 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
jcenter()
}
dependencies {
compile 'org.mechdancer:linearalgebra:0.2.5-dev-3'
implementation 'org.mechdancer:linearalgebra:${latest_version}'
}
```

Expand All @@ -37,7 +37,7 @@ dependencies {
<dependency>
<groupId>org.mechdancer</groupId>
<artifactId>linearalgebra</artifactId>
<version>0.2.5-dev-3</version>
<version>latest_version</version>
<type>pom</type>
</dependency>
```
Expand Down
176 changes: 88 additions & 88 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.3.50" apply (true)
// id("org.jetbrains.dokka") version "0.9.18"
// id("com.jfrog.bintray") version "1.8.4"
// `maven-publish`
id("org.jetbrains.dokka") version "0.9.18"
id("com.jfrog.bintray") version "1.8.4"
`maven-publish`
`build-scan`
}

Expand Down Expand Up @@ -33,96 +33,96 @@ tasks.withType<KotlinCompile> {
}
}

//tasks.dokka {
// outputFormat = "javadoc"
// outputDirectory = "$buildDir/javadoc"
//}
tasks.dokka {
outputFormat = "javadoc"
outputDirectory = "$buildDir/javadoc"
}

//val doc = tasks.register<Jar>("javadocJar") {
// group = JavaBasePlugin.DOCUMENTATION_GROUP
// description = "Assembles Kotlin docs with Dokka"
// archiveClassifier.set("javadoc")
// from(tasks.dokka)
//}
val doc = tasks.register<Jar>("javadocJar") {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka"
archiveClassifier.set("javadoc")
from(tasks.dokka)
}

val sources = tasks.register<Jar>("sourcesJar") {
group = JavaBasePlugin.BUILD_TASK_NAME
description = "Creates sources jar"
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
//
//val fat = tasks.register<Jar>("fatJar") {
// group = JavaBasePlugin.BUILD_TASK_NAME
// description = "Packs binary output with dependencies"
// archiveClassifier.set("all")
// from(sourceSets.main.get().output)
// from({
// configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
// })
//}
//
//tasks.register("allJars") {
// group = JavaBasePlugin.BUILD_TASK_NAME
// description = "Assembles all jars in one task"
// dependsOn(doc, sources, fat, tasks.jar)
//}
//
//val rename = tasks.register("renamePomFile") {
// dependsOn(tasks.publishToMavenLocal)
// doLast {
// val path = "${buildDir.absolutePath}/publications/maven/"
// val old = File(path + "pom-default.xml")
// val f = File("$path${project.name}-$version.pom")
// old.renameTo(f)
// }
//}
//
//tasks.bintrayUpload.configure {
// dependsOn(rename)
//}
//
//bintray {
// user = "berberman"
// key = System.getenv("BintrayToken")
// setConfigurations("archives")
// val v = version.toString()
// val url = "https://github.com/MechDancer/linearalgebra"
// publish = true
// pkg.apply {
// name = project.name
// desc = "linearalgebra kotlin utilities"
// repo = "maven"
// userOrg = "mechdancer"
// githubRepo = "MechDancer/linearalgebra"
// vcsUrl = "$url.git"
// issueTrackerUrl = "$url/issues"
// publicDownloadNumbers = true
// setLicenses("WTFPL")
// version.apply {
// name = v
// vcsTag = v
// websiteUrl = "$url/releases/tag/$v"
// }
// }
//}
//
//publishing {
// repositories {
// maven("$buildDir/repo")
// }
//
// publications {
// create<MavenPublication>("maven") {
// from(components["java"])
// }
// }
//}
//
//artifacts {
// add("archives", tasks.jar)
// add("archives", fat)
// add("archives", sources)
// add("archives", doc)
// add("archives", File("${buildDir.absolutePath}/publications/maven/${project.name}-$version.pom"))
//}

val fat = tasks.register<Jar>("fatJar") {
group = JavaBasePlugin.BUILD_TASK_NAME
description = "Packs binary output with dependencies"
archiveClassifier.set("all")
from(sourceSets.main.get().output)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}

tasks.register("allJars") {
group = JavaBasePlugin.BUILD_TASK_NAME
description = "Assembles all jars in one task"
dependsOn(doc, sources, fat, tasks.jar)
}

val rename = tasks.register("renamePomFile") {
dependsOn(tasks.publishToMavenLocal)
doLast {
val path = "${buildDir.absolutePath}/publications/maven/"
val old = File(path + "pom-default.xml")
val f = File("$path${project.name}-$version.pom")
old.renameTo(f)
}
}

tasks.bintrayUpload.configure {
dependsOn(rename)
}

bintray {
user = "berberman"
key = System.getenv("BintrayToken")
setConfigurations("archives")
val v = version.toString()
val url = "https://github.com/MechDancer/linearalgebra"
publish = true
pkg.apply {
name = project.name
desc = "linearalgebra kotlin utilities"
repo = "maven"
userOrg = "mechdancer"
githubRepo = "MechDancer/linearalgebra"
vcsUrl = "$url.git"
issueTrackerUrl = "$url/issues"
publicDownloadNumbers = true
setLicenses("WTFPL")
version.apply {
name = v
vcsTag = v
websiteUrl = "$url/releases/tag/$v"
}
}
}

publishing {
repositories {
maven("$buildDir/repo")
}

publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}

artifacts {
add("archives", tasks.jar)
add("archives", fat)
add("archives", sources)
add("archives", doc)
add("archives", File("${buildDir.absolutePath}/publications/maven/${project.name}-$version.pom"))
}
10 changes: 5 additions & 5 deletions src/main/kotlin/org/mechdancer/geometry/rotation3d/Angle3D.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,24 @@ sealed class Angle3D(val first: Angle, val second: Angle, val third: Angle, val
firstAngle = .0 /* arbitrary */
/* matrix.get(2, 1) == sin(firstAngle + thirdAngle) */
/* matrix.get(1, 1) == cos(firstAngle + thirdAngle) */
thirdAngle = (atan2(matrix.get(2, 1), matrix.get(1, 1)) - firstAngle)
thirdAngle = (atan2(matrix[2, 1], matrix[1, 1]) - firstAngle)
}
doubleEquals(test, -1.0) -> {
secondAngle = PI
firstAngle = .0 /* arbitrary */
/* matrix.get(1, 2) == -sin(firstAngle - thirdAngle) */
/* matrix.get(1, 1) == cos(firstAngle - thirdAngle) */
thirdAngle = (firstAngle - atan2(-matrix.get(1, 2), matrix.get(1, 1)))
thirdAngle = (firstAngle - atan2(-matrix[1, 2], matrix[1, 1]))
}
else -> {
/* matrix.get(0, 0) == cos(secondAngle) */
secondAngle = (if (neg) acos(matrix.get(0, 0)) else -acos(matrix.get(0, 0)))
secondAngle = (if (neg) acos(matrix[0, 0]) else -acos(matrix[0, 0]))
/* matrix.get(0, 1) == sin(firstAngle) * sin(secondAngle) */
/* matrix.get(0, 2) == cos(firstAngle) * sin(secondAngle) */
firstAngle = atan2(matrix.get(0, 1) / sin(secondAngle), matrix.get(0, 2) / sin(secondAngle))
firstAngle = atan2(matrix[0, 1] / sin(secondAngle), matrix[0, 2] / sin(secondAngle))
/* matrix.get(1, 0) == sin(secondAngle) * sin(thirdAngle) */
/* matrix.get(2, 0) == -(cos(thirdAngle) * sin(secondAngle)) */
thirdAngle = atan2(matrix.get(1, 0) / sin(secondAngle), -matrix.get(2, 0) / sin(secondAngle))
thirdAngle = atan2(matrix[1, 0] / sin(secondAngle), -matrix[2, 0] / sin(secondAngle))
}
}
}
Expand Down

0 comments on commit 321373a

Please sign in to comment.