How to visualize the data?
Opened this issue · 3 comments
danteppc commented
Hey!
I'm writing a similar project, I collect acceleration and gravity data, but I have no idea on how to simulate the actual movement on a 3D space i.e. SceneKit
Any ideas?
Deleted user commented
Hey @danteppc did you ever manage to find a solution to this?
Deleted user commented
Great that you did. Do you have any screenshots of what it ended up looking
like?
Thanks,
Jeremy
…On Sat, 16 Jan 2021 at 18:33, danteppc ***@***.***> wrote:
Hey @danteppc <https://github.com/danteppc> did you ever manage to find a
solution to this?
Hey!
Yeah I did something like this:
`
for i in 0..<xs.count {
//let index: Double = Double(i + 1)
agg_t += 0.01
// speed = lastSpeed + (currentAcceleration - lastAcceleration)/2 * INTERVAL
let accel = shot.accelerationsOrdered[i]
var speed = Velocity()
var distance = Distance()
speed.x = lastSpeed.x + lastAccel.x + (accel.x - lastAccel.x)/2.0
speed.y = lastSpeed.y + lastAccel.y + (accel.y - lastAccel.y)/2.0
speed.z = lastSpeed.z + lastAccel.z + (accel.z - lastAccel.z)/2.0
// location = lastLocation + (currentSpeed - lastSpeed)/2 * INTERVAL
distance.x = lastDistance.x + lastSpeed.x + (speed.x - lastSpeed.x)/2.0
distance.y = lastDistance.y + lastSpeed.y + (speed.y - lastSpeed.y)/2.0
distance.z = lastDistance.z + lastSpeed.z + (speed.z - lastSpeed.z)/2.0
lastAccel = accel;
lastSpeed = speed;
lastDistance = distance;
totalDistanceTraveled.x += distance.x
totalDistanceTraveled.y += distance.y
totalDistanceTraveled.z += distance.z
let node = SCNNode(geometry: SCNSphere(radius: 0.4))
node.geometry?.firstMaterial?.diffuse.contents = UIColor.systemGray
node.position = SCNVector3(distance.x/5, distance.y/5, distance.z/5)
scene.rootNode.addChildNode(node)
let line = SCNNode.lineNode(from: simd_float3(0,0,0), to: simd_float3(Float(speed.x/5),Float(speed.y/5),Float(speed.z/5)), radius: 0.3)
line.position = SCNVector3(lastDistance.x/5, lastDistance.y/5, lastDistance.z/5)
scene.rootNode.addChildNode(line)
}`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ4SI4OAJZDTJKIARNII6CTS2HLV7ANCNFSM4IKV2WCA>
.
danteppc commented
https://apps.apple.com/us/app/archery-tracker/id1450784807?ls=1
the third screenshot