# Converting Degrees/Radian to Vector2 is messy

## Recommended Posts

Hi Guys,

I was wondering if some one could give me some tips on converting Degrees/Radians to Vector2. Degrees to Radians and vice versa is fine.

Im using "new Vector2((float)Math.Sin(r), (float)Math.Cos(r));" to do my conversion to Vector2. Yes, I get that the equation is usually [cos(r) , -sin(r)] but my equation suits my current orientation and ultimately does not affect my problem.

The problem I'm facing is the conversion of 90° and 180° into Vectors. When converting them I get:

·         90° = [1, -4.371139E-08] - second value should be 0.

·         180° = [-8.742278E-08, -1] - first value should be 0.

I understand that 180° is technically out of range, but just indulge me on that one, the main issue is 90°. What I am missing with those E-numbers? How do I avoid them?

After writing this I thought of just including a lookup table for the 90° and 180° during the conversions, maybe, I guess it would depend on their precision. Assuming I do not change my orientation this should work right?

Thanks

Krom

Edited by Kromble
formatting

##### Share on other sites

Both those values are super tiny. They are essentially 0 -- just floating point inaccuracies. Nothing to worry about.

-4.371139E-08 = -0.00000004371139

##### Share on other sites

Ahh cheers thanks mate...

I guess the compiler can interpret this number fine.

Krom

## Create an account

Register a new account

• ### Similar Content

• Hey all,

So I have this unfathomable obsession with the games LIMBO and INSIDE, two games produced by Playdead Studios. But as a sound designer, I'm specifically into the audio of the game, its use of ambient tracks and specific sounds to create this level of emotion I've never felt in a platformer before.

I took a stab at redesigning the sound and ambiance of one of LIMBO's trailers to see if I could replicate such emotionality with my own creativity. Check it out below. All feedback is appreciated.
Thanks!

• Been a bit quiet recently, but we've been busy bug fixing and tweaking things... Now we have lots more 'Particle effects' in the game, specifically here the Flamethrower and Enemy attacks!
• By Gezu
Hi,
I'm working on Warriorb for about 2,5 years now and recently we made a playable version of the first part of the game. There are still some elements missing (mostly vfx and sfx) but most of it is close to final.
I would love to hear what do you think about our game so far. Any critique, feedback, idea or tip is appreciated.
If you are interested send me a pm and I will give you a steam key for the game.
Gézu

• So, as the title says i am trying to figure out a good way sync all that information with other players in Unity. My problem is that i can't come up with a good solution since i am used to creating classes for everything e.g. attachments are its own class and then the weapon would save a reference to that attachment. But since you can't send custom classes over [Command] & [ClientRPC] i am a little stuck. A solution for this would be giving each attachment for a slot a unique ID and then passing the ID to other player but i feel like that is very error prone if other ppl add a new attachment or the IDs get mixed up.
Is there a "standard" way that this is usually done that i am missing?
I am fairly new to programming so any help is appreciated!

• Hi guys, I'm having a problem rendering with DWrite, and I don't understand why, can you help me figure it out?
As you can see in the image below, if you look carefully you'll notice that the top of R8 is cut (missing 1 row of pixels), the bottom of R11 is cut again, the 4 in R14 is rendered weird compared to the 4 in R4 and so on, if you look closely you'll spot more yourself.
I can't figure out why 😕
Under the image I'll also leave the code, in case I'm doing something wrong like with type conversion or stuff. Any help is much appreciated

• Hello,
In the hopes that my thread is not off-topic or offensive in any way, I dare to ask the following "noob" question:
what would be the correct way to create sprite animations from 2D *.bmp files?
with the help of some tools i found , I was able to extract files containing what seems to be animation frames and frame shadow masks for animating a horse.
Attached are the archived assets.
My goal is to recreate the demo level of the game using Unity, for educational purposes.
I have started by loading the background map layer (also a large bmp file), and next step is to load a 2d character object and animate on the perspective.

Horse_Brown.rar

• Hello, my name is Alberto Muratore and I'm a young game developer specialized in programming.

Last summer I finished working on Abstract Arena, my first completed project published on Steam. During the development, lasted more than 1 year, I created every aspect of the game except for the audio sector. I previoulsy joined small competitions and had collaborations within the amateur scene, since I started having fun with game development when I was a kid. In the recent months I also started writing videogames reviews for a english-italian website about indie games.

Abstract Arena Steam page: http://store.steampowered.com/app/678230/Abstract_Arena/
Abstract Arena website: http://www.abstractarena.com/

I'm currently offering my skills as freelancer in the role of programmer: what I'm searching for is a project that only lacks of the coding part. I'm very good at using the GameMaker: Studio engine, and I already own a license to export on Android platform. I can write code for any genre of 2D games, and I already have experience with the peculiarities of the Android platform (multiple touch controls, accelerometer). I will be able to start working full time only during September, so be aware of that.

The plan is the following:
1 - you have an idea about your next project (2D game of any kind, for Windows and/or Android platform),
2 - you (or your team) create all of the graphics and audio resources,
3 - I write the whole code for the game (gameplay, menus and anything within the game) putting everything togheter [during September],
4 - if you like my work you can choose how much to pay for it, and you (or your team) keep the rights to sell the game without sharing any percentage with me.

Thank you for reading my announcement
If you have any question, please write me at the following address: albertomurat@gmail.com
• By N Drew
I am working on a 2D SideScroller game in my own made game engine using SFML and C++.I am searching for 2D artists,especially pixel artist for making and animating characters,backgrounds and other props that can be made in any Drawing Program.The artist will become part of the team of Hammer Studios and he got a part of the Revenue Sharing.If you are interested send me a mail at:ghiurcutaandrei@gmail.com .If you are not an artist but you want to be a part of our Team,Soon we will be recruiting an C++ AI programmers that worked in SFML/OpenGL.
We work together using Discord.

• While going through a Game Design Document Template, I came across this heading - Core Game Loop & Core Mechanics Loop.
What's the difference? Can you provide some examples of an existing game?  Suppose if I am including these topics in a Game Design Document, how should I explain it so that my team can understand?

• 18
• 11
• 16
• 9
• 49
• ### Forum Statistics

• Total Topics
631397
• Total Posts
2999783
×