Jump to content

Recommended Posts

Posted

This is more of a math question than a modding question. It is for my ICBM mod and I can't really figure it out.

 

I am given point A and B. A missile is to be shot from point A to B. What would the trajectory (rotationPitch) of the missile be in angles? Also, what direction (rotationYaw) will the missile shoot in angles?

 

I tried using Tangent but it didn't really work properly. I looked at the EntityArrow class as a reference but they already had the rotationYaw and rotationPitch as known variables (they get the variables from the entity player's rotation).

 

LaunchYaw will be the direction of the missile the missile being shot. LaunchPitch will be the trajectory of the missile.

this.setLocationAndAngles(position.x, position.y, position.z, launchYaw, launchPitch);

 

I am guessing the solution would be related to sine cosine, tangent functions. Since I know the two points, I know the distance between the two points.

 

AngleQuestion.png

Posted

having done some quick research anything luanched into suborbit is at roughly a 78 degree angle, looking at some pictures of test missle impacts the return angle is about 45 degrees-90 degrees

 

suborbit is about 160–2,000 km (100–1,240 miles) above the Earth's surface

the entre speed and reentry speed is about  7 km/s(entry) 4km/s (reentry)

hope this helps

Posted
  On 5/19/2012 at 1:27 PM, starwolfminecrafter said:

having done some quick research anything luanched into suborbit is at roughly a 78 degree angle, looking at some pictures of test missle impacts the return angle is about 45 degrees-90 degrees

 

suborbit is about 160–2,000 km (100–1,240 miles) above the Earth's surface

the entre speed and reentry speed is about  7 km/s(entry) 4km/s (reentry)

hope this helps

 

Sorry but that's not what I was looking for. I posted a image of what I'm trying to get above.

Posted

You want the bearing of the rocket? If so, that's equivalent to tan-1(distance between source and where you put the angle 0 text on that image/distance between target and source).

 

See this image: 500px-TrigonometryTriangle.svg.png

 

Point B is your destination, point A is your source and point C is required to work out the length of line b,  which goes into the tan function.

Posted
  On 5/19/2012 at 1:41 PM, Jarofdoom said:

You want the bearing of the rocket? If so, that's equivalent to tan-1(distance between source and where you put the angle 0 text on that image/distance between target and source).

 

See this image: 500px-TrigonometryTriangle.svg.png

 

Point B is your destination, point A is your source and point C is required to work out the length of line b,  which goes into the tan function.

Yes, I want to find the bearing of the rocket.

 

Good solution, but I do not know the point C and also the line B. How would I calculate to find that? Point C is required in order for me to use tangent.

Posted

Point C is simply the point where your lines intersect at right angles

on the 0-degree line. Therefore point C has the same X value as A and same Y as B. For an example calculation, let point A be of co-ordinate (1,2) and point B be co-ordinate (4,5) This means point C has co-ordinates (1,5). Next, we get line b and c. b=sqrt((4-1)^2+(5-2)^2)=4.24264069 c=sqrt((1-1)^2+(5-2)^2)=3 . Next, we plug this into Tan^-1 to get Angle=Tan^-1(3/4.24264069)=35.26 degrees, or 0.6154797 radians.

Posted
  On 5/19/2012 at 2:22 PM, Jarofdoom said:

This is all GCSE-level trigononmetry, BTW.

 

Sorry, but I am only in junior high school. :) If I am not as good as you in math, I will not be surprised. But anyway, thanks for the reply. I feel stupid I didn't thought of that solution. I was trying to think too hard when it's something really simple. Thanks.

Posted
  On 5/19/2012 at 2:57 PM, Jarofdoom said:

  Quote

  Quote

This is all GCSE-level trigononmetry, BTW.

 

Sorry, I just got in high school. :)

 

You'll be a couple steps ahead then :P

 

I would argue that you can't really make assumptions based on age/education.

 

In my high school you learn basic trig in geometry, and then real trig is entirely optional.

I accidentally the everything then NullPointerException.

Posted
  On 5/19/2012 at 5:57 PM, CowedOffACliff said:

  Quote

  Quote

  Quote

This is all GCSE-level trigononmetry, BTW.

 

Sorry, I just got in high school. :)

 

You'll be a couple steps ahead then :P

 

I would argue that you can't really make assumptions based on age/education.

 

In my high school you learn basic trig in geometry, and then real trig is entirely optional.

 

No assumptions were made. What are you on about? SoHCaHToA *is* basic trig...

Posted
  On 5/19/2012 at 2:55 PM, calclavia said:

  Quote

This is all GCSE-level trigononmetry, BTW.

 

Sorry, but I am only in junior high school. :) If I am not as good as you in math, I will not be surprised. But anyway, thanks for the reply. I feel stupid I didn't thought of that solution. I was trying to think too hard when it's something really simple. Thanks.

Wow... Glad to find a kindred spirit!    :D

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Posted
  On 5/20/2012 at 10:12 PM, atrain99 said:

  Quote

  Quote

This is all GCSE-level trigononmetry, BTW.

 

Sorry, but I am only in junior high school. :) If I am not as good as you in math, I will not be surprised. But anyway, thanks for the reply. I feel stupid I didn't thought of that solution. I was trying to think too hard when it's something really simple. Thanks.

Wow... Glad to find a kindred spirit!    :D

You need to take gravity into account here. A missile usually goes into suborbit, but if you are just firing it over a *short* distance, then you should be able to make a parabolic path... I have no idea how to do it (Algebra II is not helping here), but google knows...  :P

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Posted
  On 5/20/2012 at 10:59 PM, calclavia said:

I figured out a solution for my problem but the result is completely different from this. I simply used the atan2() java function to get the radians and convert it into a angle.

That works! Glad you solved your problem!

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Posted
  On 5/20/2012 at 10:59 PM, calclavia said:

I figured out a solution for my problem but the result is completely different from this. I simply used the atan2() java function to get the radians and convert it into a angle.

 

The answer is not completely different. atan = tan^-1

Posted
  On 5/21/2012 at 12:03 AM, calclavia said:

I haven't learn this in school yet. But can you please tell me the difference between atan and atan2 functions in Java? Atan2 seems to work an atan does not work.

Just play around with the console. The atan function may be using radians as it's primary in/out, so a value above 2pi may not work or be wonked out.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Posted
  On 5/21/2012 at 12:26 AM, atrain99 said:

  Quote

I haven't learn this in school yet. But can you please tell me the difference between atan and atan2 functions in Java? Atan2 seems to work an atan does not work.

Just play around with the console. The atan function may be using radians as it's primary in/out, so a value above 2pi may not work or be wonked out.

 

This, but also see http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#atan2%28double,%20double%29

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello , when I try to launch the forge installer it just crash with a message for 0,5 secondes. I'm using java 17 to launch it. Here's the link of the error :https://cdn.corenexis.com/view/?img=d/ma24/qs7u4U.jpg  
    • You will find the crash-report or log in your minecraft directory (crash-report or logs folder)
    • Use a modpack which is using these 2 mods as working base:   https://www.curseforge.com/minecraft/modpacks/life-in-the-village-3
    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.