You are invited to Log in or Register a free Frihost Account!

# New math problem a vector floating in space

chasbeen
Here is the problem.

I need a generic solution for wherever the vector is located in space.

To simplify the problem here is a real life (as near as possible) equivalent situation.

A pole (The vector) is 5 feet long has a sharp end and round end. It has a sharp end and a round end.

Children are playing with the pole trying to throw it so that it land within a square 5 feet by 5 feet.

Occasionally they succeed and the pole's entire length lies within the perimeter of the square

With every attempt a line of the pole is used to measure the distance to the edge of the rectangle to see how far the sharp edge is away from the edge of the 5 feet by 5 feet square.

All we are allowed to assume is the angle that the pole lies at. (We are always looking at the square from the same side)

What formula can be used to determine the distance between the sharp end of the pole from the edge of the square which is being pointed to???????????????

(Note this is the distance from the sharp end to the edge using the angle the pole lies in and not the shortest distance to the edge)
Bikerman
So a specific instance could look like this? (just checking I understand):
chasbeen
Bikerman
I think i'm there.
Used trigonometry and pythagoras.
Bikerman
Look like a bit of a slog tho...I'm looking for a shortcut, otherwise I agree trig is the way to go.
I presume you transpose the stick down so it intersects the left corner (same solution) and then started constructing right triangles?
chasbeen
I'm expecting the method to mature and then gradually refine it.
First objective. As long as it works!

I'm creating gradients in SVG Specification land but the underlying software has to be made to react as per the spec.

The vector is at different length as it may well have had to undergo some matrix math (That black box is now bullet proof code).

That being said the software needs to alter the stop color percentage (A percentage value indicating the target color at that percentage value along the vector that represents the gradient) so that it complies with the SVG specification but also works for the software. (The vector might end before the edge but you have to artificially add a fill so that the color matches the specification)

The software will draw the gradient incorrectly across the bounding box of the shape (A bounding box is a rectangle that exactly encapsulates the shape)

However (and to cut a long story shortish)
The right angle triangles are constructed around the landing position of the vector.
Depending on the distance of the vector from the edges (North South etc) additional right angle triangles have to be created to reduce or increase the parameters for the Sin and Cos calls.

The aggregate values (Stop color percentages) of the visible part of the vector within the bounding box can then be calculated and its equivalent syntax/metadata can be generated.

Footnotey:SVG is an extremely light and efficient method of reproducing images. They also contain data which of course their raster (images) equivalent cannot do as they hold only pixels.
Bikerman
Ahh...OK, I can see what you are doing.
Sound like you are doing some game coding..or is it a simulation?
chasbeen
Well it's not a game.

It's not software (Directly)

I am writing a part of a program that is based on the specification here:

http://www.w3.org/TR/SVG/pservers.html
Bikerman
Cool - who is it for? W3C? Commercial? Hobby/interest?
chasbeen
So that SVG can be used cross-browser.
IE (8 and below) cannot display SVG
It is a huge subject. The first part largely concerns the drawing of "paths". This involves for example the drawing of lines and shapes using Arcs, Bezier curves (Quadratic and Cubic)

All this is done and I've moved on to Linear and Radial gradients.

Whats the point of SVG?
Reason 1
Your pictures can hold data and raster images cannot they are just pixels..
Bikerman
I must admit that svg has passed me by mostly. I know a tiny bit like it uses vector graphics rather than bitmap/pixels (but knowing the acronym gives you that much). Other than that I don't think I've ever used the format myself...
chasbeen
No but you would have been using it all the time (Since 99) if the goliath Microsoft had supported the specification.

Now that IE9 has / is going to include it. It will now be true cross-browser.

Watch out for the term SVG (Its in direct conflict with Microsoft's older propprietory technology: VML and their latest proprietory technology: SILVERLIGHT)
Bikerman
Silverlight has been a pain for me. It clashed with something I have installed but intermittently so I never managed to trace which dll it wouldn't work with - I know it was a directx plugin (audio) but it could have been any of 5. In the end I got fed-up and uninstalled silverlight.
I use firefox mainly as the browser - I've always had issues with IE - I often use LaTeX or TeX environments on the net for formulae or other typesetting and the older vesions all managed to either screw up completely or distort the smbols. The new one is supposed to sort it all out but I've got used to firefox and it has been stable (apart from the latest upgrade which took exception to one of my plugins and had to be uninstalled and re-installed)
I'll be watching SVG with interest..
chasbeen
Thats excellent Chris.

I have helped engineers, teachers, Universities and many people around the world with some tricky problems solved with SVG

Last Thursday I got hit by a DDOS attack and my provider brought my site down for good.

DDos attack was very sophisticated (Informed by top internet security guy after data analysis) so I wonder who the hell had it in for me.

I have at last got ny domain back and am rebuilding the site (With extra security)

Only problem is I'm flying into Heathrow tomorrow to start a 2 week holiday and I will only be persueing this effort slowly until the beginning of September.
chasbeen
Chris

heres the other thread I put up about shared servers and service providers...

http://www.frihost.com/forums/vt-118146.html#973978
Bikerman
 chasbeen wrote: Thats excellent Chris. I have helped engineers, teachers, Universities and many people around the world with some tricky problems solved with SVG Last Thursday I got hit by a DDOS attack and my provider brought my site down for good. DDos attack was very sophisticated (Informed by top internet security guy after data analysis) so I wonder who the hell had it in for me. I have at last got ny domain back and am rebuilding the site (With extra security) Only problem is I'm flying into Heathrow tomorrow to start a 2 week holiday and I will only be persueing this effort slowly until the beginning of September.

If you are planning to come North then you should call me and we'll go out for a pint (you are also welcome to put-up here if you need somewhere to crash on your travels - we have plenty of room). Let me know if you are, and I'll send you some contact details - I live in Cheshire (see map).
chasbeen
Thanks for the offer.

I will be knocking around the South East on a tight schedule. We considered a trip to Weymouth but realised we could not fit that in either.

Next time I am back in the UK (After this visit) it might be permanent and maybe do that then.

Charles
Bikerman
Anytime - consider the invite open-ended.
Indi
Well i'm glad to see someone else around here is working with SVG.
Bikerman
On the DDOS attack - there is a worrying increase in the sophistication in many recent attacks, not just yours. One method I've seen is to start with simple 'head' requests and then when detected and filtered, immediately switch to 'get' requests on the root directory. When that is spotted and filtered, the attack switches instantly to random page 'get', and when that is filtered it switches back to head requests. Very difficult to counter....

The real worry is the number of recruits for these attacks - often 300 plus client IPs can be involved attacking sites which wouldn't attract a major attack normally. It suggests to me that there is a new trojan/bot making the rounds and recruiting hapless PC owners into these attacks - so that one or two hackers can launch a powerful attack. Such software has been around for some time but is normally guarded jealously and only wielded against the big targets...
Bikerman
 Indi wrote: Well i'm glad to see someone else around here is working with SVG.

I'm wondering how SVG will fit with the new HTML5 'canvas' standard. Seems pretty similar to my inexpert eyes, though canvas looks to be a lower level implementation if I have understood the spec...
chasbeen
Hi B
Back from the good old UK.
What a holiday, you cannot beat where your from.
Looking forward to more online adventure..
As discussed I'm resurrecting my website at present.
C
infinisa
 chasbeen wrote: Here is the problem. I need a generic solution for wherever the vector is located in space. To simplify the problem here is a real life (as near as possible) equivalent situation. A pole (The vector) is 5 feet long has a sharp end and round end. It has a sharp end and a round end. Children are playing with the pole trying to throw it so that it land within a square 5 feet by 5 feet. Occasionally they succeed and the pole's entire length lies within the perimeter of the square With every attempt a line of the pole is used to measure the distance to the edge of the rectangle to see how far the sharp edge is away from the edge of the 5 feet by 5 feet square. All we are allowed to assume is the angle that the pole lies at. (We are always looking at the square from the same side) What formula can be used to determine the distance between the sharp end of the pole from the edge of the square which is being pointed to??????????????? (Note this is the distance from the sharp end to the edge using the angle the pole lies in and not the shortest distance to the edge)

Hi there, this is an interesting problem and a fascinating thread about SVG, but the original problem doesn't seem to have been solved yet!

Let's suppose that the rod lies at an angle θ to one side of the square. Unfortunately, this doesn't seem to be enough information to solve the problem.

Even if we assume the simplest case - that the line extending the rod within the square meets the square at opposite sides, all we can say is that this extended line has length 5 sec α (where α is the smaller of θ and 90º - θ), so the sum of the distances of each end to the edge of the square is 5 sec α - 5. But we don't know how much is at the round end and how much at the sharp end.

If the the line extending the rod within the square meets the square at adjacent sides, then we are really stuck for more info...

Am I on the right track?
chasbeen
The problem was to do with calculating vector angles and lengths.
The underlying software had to recalculate the colours of the linear gradient in an unconventional way so that it would match the SVG specification.
The software would paint the shape incorrectly because it assumed the pole completely traversed the shape when in reality it would only partially traverse the shape.
The length of the pole would (potentially) not traverse the shape entirely after it had been transformed (Example of transform is rotate)
The program now works out the correct colors of the gradient by using 2 right angled triangles.
The distances necessary for the 2 triangles can be derived so that the 2 sides that constitue the length of the pole can be derived.
I'm currently working on a new problem for the same program. It involves a thing called radial gradient.
The above is the max knowledge I can remember on that previous problem. I won't be discussing that one further. I might stick something up on the new or subsequent one however.