Search Unity

mathf.sin cos tan?

Discussion in 'Scripting' started by Wasiim, May 26, 2015.

  1. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    Yes i am familliar to these functions in Geometry but what purpose do they serve in unity? Soh Cah Toa
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    When 3d applications are implemented, there are a lot of geometrical problems that need to be solved. For some of them, it is straight forward to use trigonometric functions.
    For me the question is more, why should they not be needed in Unity?
     
    Kiwasi likes this.
  3. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    For me to decide if they should not be needed i need a thorough explanation.
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,141
    If the use of sine, cosine, and tangent functions in geometry/trigonometry isn't obvious, then you're unlikely to understand the more detailed explanation. You most likely would want to start with math books covering those two fields or possibly even some classes.
     
    Last edited: May 26, 2015
    Kiwasi and ThermalFusion like this.
  5. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You find a bunch of examples here:
    http://bfy.tw/Wk
     
    ThermalFusion and Ryiah like this.
  6. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    o_O

    Really guy?

    What do you mean a thorough explanation of it? It's freaking trig dude! You said you are familiar with them... how do you NOT know what they're useful for?

    Go back to your freshman highschool math class if you don't know.
     
  7. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Your logic is nonsensical - what explanation would be required? You could pose the same question for any method provided but for what purpose. To me it makes as much sense as asking about the marital status of the number 5.

    Here is the concise explanation: They are methods that are provided to be used in instances where they are useful.

    Here are two examples:
    • Distribute/Plot points or objects in a circle
    • Create a wave effect
     
    Kiwasi, ThermalFusion and Ryiah like this.
  8. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    I'm glad you're not deciding.
     
  9. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    The bashing is strong in this thread. I really don't like it.
     
    davidnibi, davtam and Wasiim like this.
  10. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    No need to bash anyone here... We all learned some basic trigonometry and we all forgot some!

    Personally, I used a bunch of Trigonometry when I do some 2D AI stuff, like:
    -Finding the closest enemy
    -Rotating forwards something (in 3D, you can just use LookAt)

    Here's a useful link about the OP question:
    http://www.raywenderlich.com/35866/trigonometry-for-game-programming-part-1
     
    Last edited: May 26, 2015
    Wasiim and eisenpony like this.
  11. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I agree that the bashing goes too far. Still, I will never understand why someone doesn't use Google before asking questions here.
     
    blizzy and Ryiah like this.
  12. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,141
    He started off by stating he understood the purpose of sine, cosine, and tangent in math, but then asked how they're used in Unity as if they are somehow different. Additionally his second post came off a bit arrogant. Are you really surprised he was getting those responses?
     
    Last edited: May 26, 2015
  13. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I've been using the Net for too long to be able to answer Yes here.
     
    Wasiim and Ryiah like this.
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,686
    Without going off on a tangent, I'd just like to add that I use sine and cosine all the time in Unity3D. They really help me get a round.
     
  15. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    I am really stunned by some of the bashing on this thread i said i knew trig and i also mentioned i use them in geometry
    Ryiah- He started off by stating he understood the purpose of sine, cosine, and tangent in math, but then asked how they're used in Unity as if they are somehow different. Additionally his second post came off a bit arrogant. Are you really surprised he was getting those responses?

    First i just want to say what is there to be arrogant about? even though i said i am familliar as in "that one guy seems familliar" (i did not say understood) regardless the functions in geometry should not lead one to assume that i have a high level of understanding in this category i only use them to find the sides of a triangle. If you can't even answer the question at least post a link to a good source of info. Thanks to sluice,blizzy,Kurt Ddekker for not bashing.

    Best answer goes to - sluice, thanks for the link man.

    For that one guy who said my logic is nonsensical and provided these 2 explanations
    • Distribute/Plot points or objects in a circle
    • Create a wave effect
    Now you know why i asked for a thorough explanation. This definition is completely random the fact that you questioned my logic strikes me as offensive. Anyone with life experience knows that people learn at different paces and do not think alike. You might be talking to a person who will become a great programmer one day, no matter what do not use negative adjectives to describe the man or woman or their ownership please.
     
    Last edited: May 28, 2015
    davtam and sluice like this.
  16. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    ::snort::
     
  17. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,141
    They serve the same purposes in Unity that they do in math. You were asking for a thorough explanation yet the explanation was in the very math you claimed to have understood. While I suppose it is possible to learn a subject yet be unaware of its application, the books I used to learn the subjects in school had real life examples of the math in use.

    Your second post came off feeling a bit arrogant even if you hadn't intended it. It felt as if you were stating, "I'll make the decision as to whether or not they are useful in Unity".
     
    Last edited: May 28, 2015
    passerbycmc likes this.
  18. Fajlworks

    Fajlworks

    Joined:
    Sep 8, 2014
    Posts:
    344
    Perhaps it wasn't your intention, but this post struck me as arrogant as well when I first read it.

    Although the question was more or less answered, for future reference it would be more helpful to ask a question in terms of:

    "I was thinking of solving problem X with trigonometry, do you guys think I could apply it or should I tackle the problem X another way?"

    I'm sure that way more people would be eager to assist you.

    I've read somewhere (can't remember link sorry) an interesting thing about sin/cos is that, when you draw it in complex plane it is actually a spiral, not a circle as one might thought. Maybe that can provide you a better insight how to use it. Good luck!
     
  19. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    Thanks for the reply fajlworks i would have done your suggestion but i was not trying to solve a specific problem but that probably would not have mislead many.
     
  20. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    That did come off arrogant don't blame you for that. To be honest i do not know what i was attempting to say either. That was quite uninsightful(if that is a word) of me, and yes though i knew about it from geometry. One can only ask what is it that is so unclear to your needs? and yes you are right i did'nt know its application to Unity3D.

    -- You might be rich,intellectual,strong,beautiful but all that isn't a viable perquisite compared to
    the ones that give to the ones that give to others,educate others, save others,make others feel beautiful in their own individuality.
     
    Last edited: May 29, 2015
  21. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I'm sorry if you took offence but I was speaking with reason - the line of 'questioning' is indeed nonsensical to me, is that an overly offensive thing to say? I'm just saying your question doesn't really make sense. Read my reply again assuming I'm just a logical nerd who also tried to add a little humour (marital status) and it should not come across too offensive.

    I think you took more offence than necessary from my comment due to the tone this whole thread took.

    It's nonsensical since it's purpose is the same - it's for 'geometry' as the first reply indicated.

    I read your question like this bad analogy:

    "I'm familiar with how wheels turn to make a car move, but what's the purpose of having them on a truck?"

    And your:

    Came of somewhat arrogant (as has been covered). It reads as if you're saying "I need to decide if they made a mistake including these in Unity and I need a thorough explanation to convince me otherwise". I suspect that is not what you were trying to say.

    Absolutely - like I mentioned before, I think you took an unnecessary amount of offence from my post - sorry for that - if you look through my posts you'll see that over 90% will be just me offering help/assistance to others, I'm like that, I take joy from helping others, not attacking them - it assists my own learning.

    I encourage you to keep learning and engaging in this forum, do not let this thread and its tone etc effect you - I think it was mostly due to poor interpretation of your intentions.
     
  22. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    Perhaps @matriXcel should of format his question more on how/when is it best to use Trigonometry in game design?.
    I think it's a really interesting subject!

    I'm sure there are interesting scenarios where most of us (me included) wouldn't think of using trigonometry while it would actually be a really good way of fixing that problem!
     
    Last edited: May 29, 2015
  23. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I agree, it is an interesting subject. But if it was meant like that, it doesn't fit into this section, but would need to be in General Discussion. The scripting section is not for chit-chat.
     
  24. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
  25. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
  26. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    There's a series of posts on the Wolfire blog that you might find interesting, too.

    Functions like this are used for all kinds of things. In my game I use them for spawning objects on a circle around a center for example, or for finding out if a target is left or right of an object. Using Unity, you usually don't have to go down to this basic math level that Mathf.Sin/Cos/Tan etc. represent since Unity provides higher-level functions for convenience.
     
    sluice and Ryiah like this.
  27. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    Thanks for all the posts i am getting some real good juice out of this. I really love the application of math in programming. I would also love some book recommendations on this in c# better yet Unity3D c# anything from rotations(especially rotations i still do not know what quaternions are) to positioning and any math related stuff.
     
    Last edited: May 30, 2015
  28. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    When i read your post your tone seemed to me like you described the question as making no sense whatsoever(nonsensical logic), But all that is behind us so we should not ponder on such silly arguements.
     
    larku likes this.
  29. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416

    Good place to start, if you haven't already:
    http://unity3d.com/learn/tutorials/modules/beginner/scripting
    http://unity3d.com/learn/tutorials/modules/intermediate/scripting/quaternions
     
  30. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
  31. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hm, that's tough. There are a gazillion books on Linear Algebra, Trigonometry etc. out there, but not specifically for C#. If you find a C# book it won't deal with those topics, since low level stuff like this is usually coded in lower level languages. There are Unity/C# books but those should be quickly outdated - and if they are not they are too general.

    That being said, the only thing that I can think of right now that is about low level gaming math and C# is Jamie King's YouTube series on the subject. There you will find explanations of basic C# concepts, C# usage patterns, low level math etc.
     
    Wasiim likes this.
  32. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    Yes i am familliar with Jamie King's series as well as jonathan weinberger,awfulmedia,acem003 etc. but i will look into it with more insight.
     
  33. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
  34. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
  35. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    No probs, fair call - do note that linear algebra is an extremely useful tool for games programming in general - it'll equip you with a whole new arsenal of ways to solve things.

    The problem with waiting until you have a problem that needs it is that you won't know the solution/method exists and will not know that is the time to learn (if I'm making any sense).
     
    Ryiah likes this.