Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 15:30

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Objekt um Fixpunkt drehen

Discussion on Objekt um Fixpunkt drehen within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 14
The Black Market: 108/0/1
Join Date: May 2011
Posts: 2,671
Received Thanks: 818
Objekt um Fixpunkt drehen

Hey, ich habe eine Frage, welches keine direkte Programmiersprache betrifft, sondern welche auf alle Anwendbar ist.
Ich habe ein Objekt.
Dies ist ein 2D-Vektor. (Somit X und Y Achse).
Nun habe ich einen Fixpunkt (auch ein 2D-Vektor).
Wie kann ich nun das Objekt in einem bestimmten Abstand mit einer bestimmten Geschwindigkeit um den Fixpunkt drehen lassen?
Ich bräuchte nur die Formel.
vwap is offline  
Old 01/28/2012, 09:34   #2
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
Gegeben sind y, x und a:
y' = sin(a + atan(y/x)) * sqrt(x^2 + y^2)
x' = cos(a + atan(y/x)) * sqrt(x^2 + y^2)

x' und y' sind die neuen Postionen von x und y, ausgegangen davon, dass der Punkt um den gedreht wird (0|0) ist.

Ich weiß nicht, ob es funktionieren wird. Ich gehe aber davon aus
jacky919 is offline  
Old 01/28/2012, 11:06   #3
 
elite*gold: 14
The Black Market: 108/0/1
Join Date: May 2011
Posts: 2,671
Received Thanks: 818
Genau so hab ich's schon versucht, klappt aber nicht.
Habs jetzt aber selbst gelöst
vwap is offline  
Old 01/28/2012, 12:02   #4
 
elite*gold: 9
Join Date: Dec 2009
Posts: 1,071
Received Thanks: 819
Wie? Würde mich auch interessieren!
.Infinite is offline  
Old 01/28/2012, 21:41   #5
 
elite*gold: 14
The Black Market: 108/0/1
Join Date: May 2011
Posts: 2,671
Received Thanks: 818
Code:
 proton.position.X = graphics.PreferredBackBufferWidth / 2;
                proton.position.Y = graphics.PreferredBackBufferHeight / 2;
// ^ position, um die sich das objekt drehen soll (bildschirmmitte)

                proton.angle += 0f; // Drehgeschwindigkeit
                proton.angle %= MathHelper.TwoPi;

                if (proton.distance > 40f) proton.distance -= (float) rand.Next(0, 5) / 10; // proton.distance ist der abstand vom rotierungspunkt
                
                var protonPos = new Vector3(proton.position.X, proton.position.Y, 0);
                var origin = new Vector2(proton.texture.Width, proton.texture.Height) / 2f;

                Matrix mat = Matrix.CreateTranslation(new Vector3(-origin, 0)) * Matrix.CreateTranslation(new Vector3(proton.distance, 0, 0)) * Matrix.CreateRotationZ(proton.angle) * Matrix.CreateTranslation(protonPos);

                proton.position = Vector2.Transform(Vector2.Zero, mat);
"proton" ist ne eigene Klasse:
Code:
 public class Proton : Species
    {

        public float health;
        public float distance;
        public float angle;
        public float speed;

    }
Leitet sich von Species ab:
Code:
public class Species
    {

        public Texture2D texture;
        public int id;
        public Vector2 position;

    }
vwap is offline  
Old 01/28/2012, 22:07   #6
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
ok, ich wusste natürlich nicht, dass dir Matrizen zur Verfügung stehen...
jacky919 is offline  
Reply


Similar Threads Similar Threads
problem mit 3d objekt
10/25/2011 - Minecraft - 1 Replies
habe ich schon geschaft
Infizierte Objekt?
10/25/2011 - Technical Support - 1 Replies
Ich glaube ich habe ein Virus auf den Laptop :( Ich habe mir ein Spiel runtergeladen, aber Egal. Würde mich Freuen wenn ihr mir sagen würdet ob ich was drauf habe oder nicht! HiJackThis: Logfile of Trend Micro HijackThis v2.0.4 Scan saved at 11:04:46, on 25.10.2011
Objekt einfügen???
06/03/2011 - Minecraft - 4 Replies
Hey Leute, ich habe mir ein Objekt (jmd hat es gebaut, die dateien kopiert und zum herunterladen ins netz gestellt) heruntergeladen und möchte nun das Objekt an einer bestimmten stelle platzieren. meine frage lautet: wo muss ich die dateien einfügen, und wie kann ich das objekt an einer bestimmten stelle platzieren?? thx im vorraus
objekt values ?!
03/25/2011 - Metin2 Private Server - 5 Replies
eine frage Wo finde ich die objekt values ???!!!!!!
Suche Objekt id :P
09/13/2010 - WoW Private Server - 4 Replies
Hi, in Theramore ist eine Wehrzitadelle. Frage: - Ist das ein Object oder Display ID? (Wenn ja) * Was ist die ID für den object? (wenn nein) Wie füge ich sowas ?



All times are GMT +1. The time now is 15:32.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.