473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Line Method Function

I am using VB5.
I wish I had a function to draw a line, giving the angle and length but I do
not have the math skills involved to do this. Does anyone have a function
that they care to share that does this?
I was thinking something like:
Public Sub DrawLine(X1 as single, Y1 as single, Len as single, Angle as
single, byref X2 as single, byref Y2 as single)
and have X2 and Y2 assigned in the Sub (rather than just a line drawn -
because I would like to do a little more processing first.

The purpose of this is that I have a Square (drawn with the line method)
that is cut in half diagonally (line method) and I would like half of it (a
triangle) shaded in with hash mark lines (user selective in what the angle
of these marks might be.)
Any help would be appreciated. I tried some searches and get lots of math
lessons but I would have a lot to learn to accomplish this. Or maybe there
is a better way?
Thanks.
Dec 4 '05 #1
2 7119

"The Mess" <em***@none.com> wrote in message
news:la*****************@news20.bellglobal.com...
I wish I had a function to draw a line, giving the angle and length but I do
not have the math skills involved to do this. Does anyone have a function that
they care to share that does this?
I was thinking something like: Public Sub DrawLine(X1 as single, Y1 as single, Len as single, Angle as
single, byref X2 as single, byref Y2 as single) Any help would be appreciated. I tried some searches and get lots of math
lessons but I would have a lot to learn to accomplish this. Or maybe there is
a better way?


I'm afraid that any answer is going to involve some math, but not that much...

If your angle is in degrees, you will need to convert it to radians:
Angle = Angle / 180 * 3.14159625

The basic formulas you need are
X2 = X1 + Cos(Angle) * Len
Y2 = Y1 + Sin(Angle) * Len

Dec 4 '05 #2
Thanks very much, Steve. That should get me in the right direction! Thought
it would be more complicated than that.
"The Mess" <em***@none.com> wrote in message
news:la*****************@news20.bellglobal.com...
I am using VB5.
I wish I had a function to draw a line, giving the angle and length but I
do not have the math skills involved to do this. Does anyone have a
function that they care to share that does this?
I was thinking something like:
Public Sub DrawLine(X1 as single, Y1 as single, Len as single, Angle as
single, byref X2 as single, byref Y2 as single)
and have X2 and Y2 assigned in the Sub (rather than just a line drawn -
because I would like to do a little more processing first.

The purpose of this is that I have a Square (drawn with the line method)
that is cut in half diagonally (line method) and I would like half of it
(a triangle) shaded in with hash mark lines (user selective in what the
angle of these marks might be.)
Any help would be appreciated. I tried some searches and get lots of math
lessons but I would have a lot to learn to accomplish this. Or maybe there
is a better way?
Thanks.

Dec 5 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Powell | last post by:
<?php class FileRemoval { var $fileNameArray, $isRemoved, $errorMsg = ''; function FileRemoval() { $this->fileNameArray = array(); $this->isRemoved = 0; }
6
by: Trevor Fairchild | last post by:
Hello, all. I am writing a program that parses an html report (generated by another program). I use the Open "C:\...." for Input As myValue method to open the html, and read through it...
1
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of...
10
by: lkrubner | last post by:
I killed last night and a good chunk of today trying to figure out this one particular attempt to get a class and initialize it. My code is using a class method called getObject to include() a file...
23
by: FrancisC | last post by:
#include <stdio.h> int file_copy( char *oldname, char *newname ); int main() { char source, destination; printf("\nEnter source file: ");
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
23
by: Kaz Kylheku | last post by:
I've been reading the recent cross-posted flamewar, and read Guido's article where he posits that embedding multi-line lambdas in expressions is an unsolvable puzzle. So for the last 15 minutes...
8
by: bahoo | last post by:
Hi, I have a text file containing a single line of text, such as 0024 How should I read it into a "list"? I tried this, but the "join" did not work as expected. Any suggestions?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.