Posted July 7, 201213 yr I've got this question and it's more of a math question (I just got into high school so please don't expect too much). I have a entity that grabs nearby blocks (block entities like sand) and spins them around the entity. Kind of like a tornado that just spins blocks in circles. How can I find the X and Z position of these spinning blocks based on - the position of the entity controlling these blocks, the radius/distance between the entity and the flying block and the rotation orbit? I currently found something similar to this: this.targetX = this.posX + xMod*orbitRadius * Math.cos(orbitDegree); this.targetZ = this.posZ + zMod*orbitRadius * Math.sin(orbitDegree); but it didn't work (pushed out all the blocks outwards and that's all). http://calclavia.com/uploads/banner.png[/img]
July 8, 201213 yr Tried inverting the addition to pull in. And add an addition inside the trig functions to rotate?
July 8, 201213 yr Author Tried inverting the addition to pull in. And add an addition inside the trig functions to rotate? What?! I don't really understand.. What I'm trying to get is to have blocks orbiting around an origin. I'm not sure what math I have to do to calculate the position of where these blocks should fly. http://calclavia.com/uploads/banner.png[/img]
July 8, 201213 yr Oh, in that case just get the cos/sin of the axis, multiply it by the distance away, and add all of that to the central X/Z point.
July 8, 201213 yr Author Oh, in that case just get the cos/sin of the axis, multiply it by the distance away, and add all of that to the central X/Z point. Isnt that the same as the code i wrote? http://calclavia.com/uploads/banner.png[/img]
July 8, 201213 yr You are also multipying by xMod/zMod, no clue what those are or what the surrounding code looks like?
July 9, 201213 yr Author You are also multipying by xMod/zMod, no clue what those are or what the surrounding code looks like? Those two variables are multiplied. They are either -1 or 1. If the position is negative, the xMod and zMod will be negative. This is used to make sure they fly the correct direction. \ The surrounding code aren't really related to this. I was testing and trying to make it orbit. Basically we have an entity that is walking around. If the entity goes close enough range to a specific position, the position will pull the entity towards it orbiting around it. Kind of like a block that has massive gravity. http://calclavia.com/uploads/banner.png[/img]
July 9, 201213 yr Hmm, should not be too hard, done things like that before, but I have no code in front of me currently... I pretty much do something just like it in my mechanics mod though for rotation purposes.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.