Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Andos

How long is this line?

This topic is 6049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm going to use this when making some strange texture effects and i need a way to find out how long a line is in an object like that one posted under this text:. If i have one of theese: .100.pixels. ....._____.... .../.........\... ../~~~~~\.. <--- ./________\. .200.pixels. How can i find out how long the "~" line is in pixels if i know hot far away the "~" line is away from one of the sides? Maby this don't make any sense but i'm not that good at english... Can you help me? [edited by - Andos on April 18, 2002 11:23:49 AM] [edited by - Andos on April 18, 2002 11:24:09 AM] [edited by - Andos on April 18, 2002 11:24:25 AM]

Share this post


Link to post
Share on other sites
Advertisement
Find the angle and use trig function to find the position of the intersection between the / and \ lines and the ~~~ line.
Then, find the distance between those two points.

Out of curiosity, what are you doing?

----------------
Blaster
Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com

Share this post


Link to post
Share on other sites
Can''t this be used?:
LengthLine1-(((LengthLine1 - LengthLine2) / 100 ) * ( ( YofLine / DistanceBetweenLine1&2) * 100 ))

I''m trying to make a wierd software texture rendering...

Share this post


Link to post
Share on other sites
L = (L2-L1)*t + L1 where t goes from zero (L1) to one (L2).
In your case t = Y/distance(L1,L2)

[Questions (STFW) | GDNet Start Here | GDNet Search | Forum FAQ | Google | Asking Smart Questions ]
[Docs (RTFM) | MSDN | SGI's STL | OpenGL | File formats]
[C++ Must Haves (RTFS) | MinGW | Boost | Loki | FLTK | SDL ]

Stolen from Magmai Kai Holmlor, who held it from Oluseyi, who was inspired by Kylotan...


[edited by - Fruny on April 18, 2002 2:20:25 PM]

Share this post


Link to post
Share on other sites
You mean:

L: Length of the line I try to find

L1: Line 1

L2: Line 2

t: Y or X / with the distance between L1 & L2

Is this correct?

Share this post


Link to post
Share on other sites
But can my other formula also be used?
In code it would maby look like this:

float
LengthLine1, LengthLine2, LENGTHOFUNKNOWNLINE

float
YofUnknownLengthLine, Distance, difference

float
YofLine1, YofLine2

//finish floating ;-)

Start loop

LengthLine1=200

LengthLine2=100

YofLine1=0

YofLine2=100

YofUnknownLengthLine=50

Diffecence=LengthLine1 - LengthLine2

Distance= YofLine2 - YofLine1

LENGTHOFUNKNOWNLINE= LengthLine1-((difference/100)*((YofUnknownLine / distance)*100))

stop loop

Share this post


Link to post
Share on other sites
((Base - Top) * .5) + Top

That should do it. Assuming that the "~" line is half the distance between the top and bottom.

I sure hope this world isn't one big joke, because I don't get it.

[edited by - VisualB4BigD on April 21, 2002 5:16:54 AM]

Share this post


Link to post
Share on other sites
Simply speaking, find the equation for each line, the height off the base, and plug in that value to each line equations to get the point on each line. Like someone said, linear interpolation.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!