/tmp/duangsuse.sock
23 subscribers
303 photos
3 videos
92 files
337 links
从 duangsuse::Echo (@dsuse) 跟进出来的分支,将在作者恢复原帐号访问的时候合并删除。
Download Telegram
Forwarded from Deleted Account
请求数学支援!急!在线等!
Forwarded from Deleted Account
需要依据某一点 P 和一个 rotation、distance 求出 P' 的 (x, y) 轴距离,忘记三角函数怎么用了来着(绝望)
手头也么得纸
Forwarded from Pani Ram
Forwarded from Pani Ram
是要求Q点吗
Forwarded from Deleted Account
应该是的
不过所有那个 象限 都要正常
Forwarded from Pani Ram
Q(x0+d*cos(theta), y0+d*sin(theta))
Forwarded from Pani Ram
theta 是弧度值的
Forwarded from Pani Ram
deg2rad _deg = _deg / 180.0 * _PI
Forwarded from Deleted Account
艹好像失败了
Forwarded from Deleted Account
看起来好像还是不对……算了吧 90+30 度……
Forwarded from Deleted Account
修好 bug,75 行终于弄成了,感动 😥
Forwarded from Deleted Account
KochHill.kt
2.1 KB
@iseki 我的基础工作已经做完了,你可以继续下去,画那个分形了啊 🌝 (注:感谢 @DuckSoft 大佬提供的公式)
Turtle.kt
2.3 KB
#Kotlin #code 画画的程序 当然只是核心部分
import kotlin.math.sin
import kotlin.math.cos
import kotlin.math.PI

protected fun forward(distance: Double) {
val pA = position
val distanceAB = distance.distanceDegree(rotation)
val pB = pA + distanceAB
canvas.drawLine(pA.x, pA.y, pB.x, pB.y)
position.assign(pB)
}
private fun Double.distanceDegree(rotation: Deg): Point2 {
val d = this; val r = rotation.coerceRad()
return Point( (d*cos(r)).toInt(), (d*sin(r)).toInt() )
}

最核心的科技
protected var rotation: Deg get() = rawRotation*FULL_DEG
set(d) { rawRotation = d/FULL_DEG }
protected fun rotate(deg: Double) { rotation += deg }
protected fun forward(distance: Double) {
val pA = position
val distanceAB = distance.lineDegreed(rotation)
val pB = pA + distanceAB
canvas.drawLine(pA.x, pA.y, pB.x, pB.y)
position.assign(pB)
}
private fun Double.lineDegreed(rotation: Deg): Point2 {
val d = this; val r = rotation.coerceRad()
return Point( (d*cos(r)).toInt(), (d*sin(r)).toInt() )
}
/** Coerce to radix from degree */
fun Deg.coerceRad() = this / 180.0 * PI
Turtle.kt
2.6 KB
#Kotlin #code Turtle 最终版本。“我真的不更了”——duangsuse
“我们就是死,也不会再多编辑一次的。”——duangsuse
Forwarded from KU 39
修复了一个关于 rotate 的 bug,看起来现在不错哦
新的 Turtle 基本操作