Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Draw Angle VB.net

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Wed Jan 06, 2010 4:17 pm    Post subject: Draw Angle VB.net Reply with quote

I'm making a force & motion program but I don't know how to draw angles?
_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Caelestis
Expert Cheater
Reputation: 0

Joined: 03 May 2007
Posts: 153

PostPosted: Thu Jan 07, 2010 12:46 am    Post subject: Reply with quote

What, are you confused about the math? Or you don't know which methods to call?
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Thu Jan 07, 2010 12:48 am    Post subject: Reply with quote

Graphics() component
Back to top
View user's profile Send private message MSN Messenger
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Thu Jan 07, 2010 3:22 pm    Post subject: Reply with quote

Caelestis wrote:
What, are you confused about the math? Or you don't know which methods to call?


The math part.

_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Caelestis
Expert Cheater
Reputation: 0

Joined: 03 May 2007
Posts: 153

PostPosted: Thu Jan 07, 2010 3:51 pm    Post subject: Reply with quote

Tell me what method you are using and what it does and I can help.
Back to top
View user's profile Send private message
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Thu Jan 07, 2010 5:45 pm    Post subject: Reply with quote

Caelestis wrote:
Tell me what method you are using and what it does and I can help.


Graphics.DrawLine Method

_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Caelestis
Expert Cheater
Reputation: 0

Joined: 03 May 2007
Posts: 153

PostPosted: Thu Jan 07, 2010 7:26 pm    Post subject: Reply with quote

Heres a discussion for the topic:
http://www.daniweb.com/forums/thread24617.html

Sorry I could not help directly, I hate VB

With math, do you have a vector that you need to draw with a magnitude and angle, or a vector with x and y components and you need to draw the line between them?

To do the first one, the length of x to pass to drawline would be cos(angle)*length_of_line and the y would be sin(angle)*length_of_line. The second one you just make points and pass them to drawline.
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Fri Jan 08, 2010 6:37 am    Post subject: Reply with quote

In C# you could do it like this:
Code:
public static Point GetVectorByLengthAndAngle(double length, double angle)
        {
            length = Math.Abs(length);
            return new Point(length * Math.Cos(angle), length * Math.Sin(angle));
        }
public Static void DrawAngle(Point pos,int length,double angle, Graphics g)
{
g.DrawLine(new Pen(Brushes.RoyalBlue,5.0f),pos,new Point(pos.X +length,pos.Y));
Point vector = GetVectorByLengthAndAngle(length,angle);
g.DrawLine(new Pen(Brushes.RoyalBlue,5.0f),pos,new Point(pos.X+vector.X,pos.Y+vector.Y));
}

_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren
Back to top
View user's profile Send private message MSN Messenger
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Fri Jan 08, 2010 7:17 am    Post subject: Reply with quote

Odecey wrote:
In C# you could do it like this:
Code:
public static Point GetVectorByLengthAndAngle(double length, double angle)
        {
            length = Math.Abs(length);
            return new Point(length * Math.Cos(angle), length * Math.Sin(angle));
        }
public Static void DrawAngle(Point pos,int length,double angle, Graphics g)
{
g.DrawLine(new Pen(Brushes.RoyalBlue,5.0f),pos,new Point(pos.X +length,pos.Y));
Point vector = GetVectorByLengthAndAngle(length,angle);
g.DrawLine(new Pen(Brushes.RoyalBlue,5.0f),pos,new Point(pos.X+vector.X,pos.Y+vector.Y));
}


This did the trick! Thanks @ other guy for help though.

_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Fri Jan 08, 2010 5:03 pm    Post subject: Reply with quote

I got it to work manually converting the code from C# to VB.net

Code:
    Public Function GetVectorByLengthAndAngle(ByVal length As Double, ByVal angle As Double)
        length = Math.Abs(length)
        Return New Point(length * Math.Cos(angle), length * Math.Sin(angle))
    End Function

    Public Sub DrawAngle(ByVal pos As Point, ByVal length As Integer, ByVal angle As Double, ByVal g As Graphics)
        g.DrawLine(New Pen(Brushes.RoyalBlue, 5.0F), pos, New Point(pos.X + length, pos.Y))
        Dim Vector As Point = GetVectorByLengthAndAngle(length, angle)
        g.DrawLine(New Pen(Brushes.RoyalBlue, 5.0F), pos, New Point(pos.X + Vector.X, pos.Y + Vector.Y))
    End Sub


But... It draws the angle upside down, the 180 line is on the top. How can I make it on the bottom? (Despite I'm not in triginometry/calc yet..)

_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Sat Jan 09, 2010 1:03 pm    Post subject: Reply with quote

Nvm got it to work by changing the length in GetVectorByLengthAndAngle for the Y point to a negative...

Doubles:
1.57 = 90 Angle
6.28 = 360 Angle

Equation 6.28 * (Angle/360)

_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Jan 09, 2010 6:47 pm    Post subject: Reply with quote

©ï & wrote:
Nvm got it to work by changing the length in GetVectorByLengthAndAngle for the Y point to a negative...

Doubles:
1.57 = 90 Angle
6.28 = 360 Angle

Equation 6.28 * (Angle/360)

That's an approximation. If you want it more accurate, you should use this: Angle in degrees = (Angle in radians * 180)/Pi.

_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren
Back to top
View user's profile Send private message MSN Messenger
Jorg hi
I post too much
Reputation: 7

Joined: 24 Dec 2007
Posts: 2276
Location: Minnesota

PostPosted: Sat Jan 09, 2010 6:56 pm    Post subject: Reply with quote

Odecey wrote:
Šī & wrote:
Nvm got it to work by changing the length in GetVectorByLengthAndAngle for the Y point to a negative...

Doubles:
1.57 = 90 Angle
6.28 = 360 Angle

Equation 6.28 * (Angle/360)

That's an approximation. If you want it more accurate, you should use this: Angle in degrees = (Angle in radians * 180)/Pi.


Code:
(DegreeToRadian(Me.TextBox1.Text) * 180) / Math.PI

    Public Function DegreeToRadian(ByVal degree As Double) As Double
        Return (Math.PI / 180) * degree
    End Function


This wont work? When The input in radians is 90 the line ends up around 157.5??

When I use Radian 0 it works fine though?

Edit:

Nvm I didn't need the * 180 / Math.PI

Thanks Hitler.

_________________
CEF will always stay alive.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites