Jump to content

[Workaround] How to convert angle to unit vector (angled stack nodes)


CaptainKipard

Recommended Posts

Thanks. That's good reference but it's only for those angles.

I've been trying to google, but I'm getting confused results. The KSP wiki says that a 45 degree angle angle should be written as [1,1], but then people say I should be using cos and sin on the angle which doesn't give those same results.

Link to comment
Share on other sites

You can't do arcsin or arccos with an angle, it's used for finding the angle of a normalized vector (magnitude=1). This graphic may help:

asinacosatan.png

If sin(alpha) = O/H, then alpha = arcsin(O/H) where A is X and O is Y (or the other way around if you wish) and H is the resultant vector

The former can be used to easily find O or H, but the latter is used almost exclusively to find alpha (the angle you're using as a reference point)

Edited by OrbitusII
Why did that graphic use alpha instead of theta???
Link to comment
Share on other sites

The KSP wiki says that a 45 degree angle angle should be written as [1,1], but then people say I should be using cos and sin on the angle which doesn't give those same results.

i think the magnitude of the x and y vectors for the nodes do not matter. As long as it gets 45 degrees, it could care less about the magnitude of the vectors.

2,2

1,1

0.5,0.5

will all net you 45 degrees

Link to comment
Share on other sites

:mad: I'm even more confused now that I was before.......

basically they're saying

cos(6.763)=X

sin(6.763)=Y (or Z in your case I think)

just make sure calculator knows 6.763 is degrees, not radians

Edited by nli2work
Link to comment
Share on other sites

Picture again:

asinacosatan.png

If you want the attachment axis to be 6.763 degrees off of +X, just take the sine of 6.763 for the Y-axis (O in the picture) and the cosine of 6.763 for the X-axis (A in the picture). Make sure your calculator is using degrees and not radians because then you'll end up with a totally different result.

This works because when using a Hypotenuse length of 1, the equation sin(alpha) = Y/H simplifies down to sin(alpha) = Y, giving you the Y-component of the triangle. The same can be done for cosine and the X-component of the triangle. These components can then be combined to create the vector (X,Y), which can be represented by the Hypotenuse of the triangle.

If you haven't taken any trigonometry courses (Pre-Calc, Calculus) I would strongly recommend it. People might say that math is useless, but they're wrong.

Edited by OrbitusII
Link to comment
Share on other sites

Ok I think I can make it work now.

If you haven't taken any trigonometry courses (Pre-Calc, Calculus) I would strongly recommend it. People might say that math is useless, but they're wrong.

I did take calculus a looong time ago. I failed it, partly because the teacher didn't explain it in a way that's easy to understand or practical. If you know of any sources (preferably video) that explain trigonometry and calculus like to a moron, then I'd like to look at it.

Link to comment
Share on other sites

I don't know of any resources besides Khan Academy off the top of my head, but KA is free and supposedly quite good. I can't advocate for it myself since I took AP Calc with a phenomenal teacher (the son of Donald Knuth, if anyone knows who that is) and I'm innately wired for math, but it's better than nothing.

Link to The Trigonometry Page

Link to comment
Share on other sites

Did the NODE{} config calls get fixed?

Herp, I should check my parts which use NODE{} and see if they're the right size now, brb.

[Edit] Put empties where you want (and pointed where you want) the connection nodes, then use NODE{} in the config to use those empties as your attach nodes

Example pic

MLyjb2e.png

[Edit3] Make sure your transform names are correct though (sorry opened the wrong model for that config). In game screen of part using NODE{}

Edited by NoMrBond
Link to comment
Share on other sites

Did the NODE{} config calls get fixed?

Herp, I should check my parts which use NODE{} and see if they're the right size now, brb.

[Edit] Put empties where you want (and pointed where you want) the connection nodes, then use NODE{} in the config to use those empties as your attach nodes

Example pic

http://i.imgur.com/MLyjb2e.png

[Edit3] Make sure your transform names are correct though (sorry opened the wrong model for that config). In game screen of part using NODE{}

I vaguely remember something about these, but never see any configs using it... whats the difference between Hinge and fixed joints?

Link to comment
Share on other sites

Wow. I wish I had known about this weeks ago. It would save so much effort. I'll try it. I guess I should be using fixed_joint. What's the correct orientation in Unity.

Sorry about that, I couldn't remember if it had been fixed or not (all NODE sizes used to come out in-game as size=0 (0.625) which was badddd news for lots of things especially after the 0.23.5/ARM joint strength based on size/size, and also for FAR where wrong size/size joints cause trouble), this prodded me to recheck parts I had made using empties/transforms/NODE{}

I vaguely remember something about these, but never see any configs using it... whats the difference between Hinge and fixed joints?

Fixed_joint for your stack nodes and hinge_joint for other (radial etc) joints, some restrictions though (last two defined joints need to be your stack_node/fixed_joint's)

Edited by NoMrBond
Link to comment
Share on other sites

Just tested. Sizes look right. Orientation must be +Z.

This makes things so much easier.

This deserves to be in the dev links thread. What's the terminology for this? All I can think of is that it's a "node node"

Edited by Cpt. Kipard
+Z not -Z
Link to comment
Share on other sites

I would be careful about using the NODE{} system, it has never worked as advertised since it was implemented. The original developer topic that introduced it has (I'm assuming) been moved into the moderator archive, and most of the experimentation people did was in that thread. There is this post that goes over a few of the rules people discovered about the system though.

Link to comment
Share on other sites

The fixes to the NODE{} system certainly weren't widely advertised, and the exact nature of what was fixed wasn't laid out in the patch notes

It would be nice to have something official from one of the developers laying out the specifics

Link to comment
Share on other sites

  • 10 years later...

I have resurrected this thread for a reason. Though they discussed the issue they never fully resolved it because they decided to use NODE{} instead.

I have been configuring stack nodes for years but due to rarely needing other than 90 degree or 45 degree angles I never truly thought about why we put in what we put in the rotational co-ordinates.

Turns out the co-ordinate system is Trigonometry, some thing I haven't actively thought of in many decades. 1 or -1 represent a straight line away from the centre of your node location along 1 of the 6 axis. 3 positive and 3 negative.

Now it can get confusing, at least for me, but a simple way to remember is this. Say you spawn the Mk1 inline cockpit into the Space Plane Hangar.

Rotation X, Y, Z in the config file. -1.0, 0.0, 0.0 would make your node point towards the left side of the hangar when staring out the door. Allowing you to attach something with a stack node to the left side of the cockpit if you had configed a node to be on it's left side. 1.0, 0.0, 0.0 would have the node point to the right side of the hangar. 0.0, 1.0, 0.0 would have it face the open door, 0.0, -0.0, 0.0 the back wall. 0.0, 0.0, -1.0 the roof. 0.0, 0.0 1.0 the floor.

For 45 degrees 1.0, 1.0, 0.0 will split the difference and have a node that points between the front and the right at a 45 degree angle from centre, etc.

But say you want some unique angle. There are 2 ways of doing it.

If you are physically building a model yourself in Blender or similar. Then you can add an empty to your project, give it a unique name, set it to show as Arrows and then point the Y axis of it in the direction you want your node to point. Then you can config the node like the following example.

    NODE
    {
        name = Join1
        transform = node1
        size = 2
        method = FIXED_JOINT
    }

The empty in the model is named node1 and it has it's positive Y axis pointing in the direction I want it to point in game.

name = is just the name in the config to set it apart from other nodes. size = is the size of the node you want. method = is to determine if the node stays still or can be moved. HINGED_JOINT is used for robotic parts where the attach node can move.

Method 2 which is what I mostly use and doesn't require access to a 3D modeling program. Use Trigonometry, cosine and sine, like working out the angles of a triangle through the lengths of the sides.

caz1Axe.jpeg

In this image X is represented by Cos and Y by Sine. The angle I have chosen is 25 degrees. So to have the node I want point to 25 degrees left of straight out the door I neet to put the Cos number in my X co-ordinate and the Sine number in my Y co-ordinate. As long as you have access to the internet or have printed out the table that gives you the Cos and Sine of each degree of a circle, then you will be able to work it out. If you are wanting an angle up or down the simply swap thr Y co-ordinate to the Z value. If you need more complicated then you will need a co-ordinate in all 3.

The circle has a 1 metre radius, so if you want to work it out in Blender you can place a 1 metre circle with 360 vertices at world centre. Go into Edit Mode and count around till you get the angle you want, then select that vertice and place the 3D cursor there. Go back to Object Mode and spawn an empty. When you look at the location info on the right, it will have the 2 measurements. If you need more complicated 3 co-ordinates then spawn a second circle at world centre that is turned 90 degrees to the first, then rotate it to the flat angle you want on the first circle before counting up it to choose the vertice you want, placing the 3D cursor there and then moving the empty to it so you can see it's 3 location measurements.

Hope this helps people.

Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

×
×
  • Create New...