Willkommen bei dotnet-snippets.de! Snippet hinzufügen Login Registrieren
Snippets in der Datenbank: 1563 | Anzahl registrierter User: 1895 | Besucher online: 138
Hauptmenü
Home
Top Ten
Zufälliger Snippet
FAQs
.NET Community
dotnet-forum.de
dotnet-kicks.de
Social

RSS Feeds
Rss Alle Snippets
Rss C#
Rss VB.NET
Rss C++
Rss ASP.NET
Partner
Member of Microsoft Community Leader/Insider Program (CLIP)

Kartesische zu Polarkoordinaten


Autor: Vertexwahn
Sprache: C++
Bewertung:
noch nicht bewertet
Anzahl der Aufrufe: 6113
  
Kick it on dotnet-kicks.de  

Beschreibung:

Kartesische zu Polarkoordinaten

Abgelegt unter: Polarkoordinaten, Koordinaten, kartesisch.



C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
float32 CalculateRotation(const vector2f& vPoint)
{
	if(Math::compare(vPoint.y, 0.0f, Math::Math::fEpsilon7))
	{
		if (vPoint.x >= 0.0f)
		{
			return 0.0f;
		} 
		else
		{
			return Math::Math::fPI;
		}
	}

	if(Math::compare(vPoint.x, 0.0f, Math::Math::fEpsilon7))
	{
		if (vPoint.y >= 0.0f)
		{
			return Math::Math::fPI/2.0f;
		} 
		else
		{
			return 3.0f/2.0f * Math::Math::fPI;
		}
	}

	//float rad = 0.0f;
	//if(!Math::compare(vPoint.y, 0.0f, Math::Math::fEpsilon7))
	float rad = std::atan(abs(vPoint.x / vPoint.y));

	if (vPoint.x >= 0)
	{
		if(vPoint.y < 0)
		{
			// 4. Quadrant
			rad += 3.0f/2.0f * Math::Math::fPI;
		}
	} 
	else
	{
		if(vPoint.y >= 0)
		{
			// 2. Quadrant
			rad += Math::Math::fPI / 2.0f;
		}
		else
		{
			// 3. Quadrant
			rad += Math::Math::fPI;
		}
	}
	
	return rad;
}
Sie haben Fragen zu diesem Snippet oder brauchen Hilfe bei der .NET Entwicklung?
Freundliche und kompetente Entwickler helfen Ihnen gern weiter im Forum für .NET Entwicklung.



Kommentare:
(Zum Schreiben von Kommentaren bitte anmelden.)



schlecht sehr gut
1 2 3 4 5 6 7 8 9 10
Nur angemeldete User können Snippets bewerten.