ActionScript 3.0 :: Intersection Of Two Vectors Using Perpendicular Product

Jun 11, 2011

I am currently working my way through a book on Game Programming in Actionscript 3, and have gotten to a formula required for collision detection on finding the intersection point of two vectors. Im not sure if the author uses vectors in the strictest definition, but the convention he uses is e.g for a vector V1 :

V1.a is the start point of the vector V1.b is the end point of the vector V1.ln is the vector perpendicular to V1 (its 'left normal') V1.vx is the difference between the x coordinate of V1.b and V1.a V1.vy similar to vx V1.dx is the same as vx , but for V1 scaled down to a unit vector (the direction vector) Now,in the example we have V1 which is the motion vector of the ship, and V2, which is the target vector (i.e the line the ship is going to collide with at some point)

In order to calculate at what point on V2 the ship will collide travelling along motion vector V1, the book gives the following code using the "perpendicular dot product" (Which i have not come across before) and creating a third vector V3 between the start point of V1 and the start point of V2 (V1.a and V2.a):

[Code]...

View 1 Replies


Similar Posts:


ActionScript 2.0 :: Retrieving The Perpendicular Angle From An Arc?

Mar 17, 2003

I'm working on the pinball game. I need to come up with a way of retreiving the right angle from an curved line. The idea is to have the ball follow a curve around the upper border of the game field. The ball itself is going to be a point, which the ball follows, so that I can use the shape of the object when doing hit detection. I'm not sure if that's relivant to the subject or not.

View 14 Replies

ActionScript 2.0 :: Vector Intersection To Pseudo?

Jul 23, 2009

as possible because I'm having a competition of some sort of..... In Flash Action Script Language Form the code of Vector Intersection will be in this way:

Code:
v3={vx:v2.p0.x-v1.p0.x, vy:v2.p0.y-v1.p0.y};
var t=perP(v3, v2)/perP(v1, v2);

[code]....

View 4 Replies

ActionScript 1/2 :: Intersection Of Line Segments Vs. HitTest?

Nov 2, 2009

I'm trying to improve upon the hitTest() function.I have a game in development that involves square robots, rectangular wall shapes, and line segment shots rotating and moving around. Without the rotation, hitTest works fine, but with rotation, problems arise.Walls at rotation 0,and square robots work fine. There is a small amount of funkyness with a rotated robot by a wall corner, but it's not very noticable.The big issue is collision of two rotated square robots.
 
I can create a function to get the line segments that make up each robot, and the check to see if any intersect. This will mean finding the location of eight points (using height and width and some trig to deal with rotation), finding the slope of eight lines, and then testing lines for intersection up to 16 times. This would be needed to find the intersection of each pair of robots. Those are worst case numbers, some colisions can be detected or ruled out before getting that far in the algorithm, but this check would need to be run every frame against all robots and walls and shots (shots could be a single line segment, though)Right now I'm talking about 8 robots max, maybe 6-20 walls, maybe 5-80 shots on screen @ 30 frames a second.
 
This is easy enough to create, but before I spend a day coding it all, I'm wondering if the computation requirements are going to make it prohibitive.(If so, I'll probably have to switch to circular robots).I feel like there should be a simple formula to find if two rectangles on a cartesian plane intersect, but I can't find one.

View 3 Replies

Actionscript 3 :: Calculate Intersection Between Shapes In Flash?

Dec 24, 2010

I need to calculate the intersection between two shapes in flash / action script. The problem is I can't access the shape's nodes and segments, and their coordinates, so there's no way I can calculate this. Do you know a way?

edit: further explanation: I imported irregular polygons from an EPS file to a movieclip with shapes in it.The mathematical solution to the problem is trivial, but to do that, I need to access by AS code to the coordinates of the nodes that make up the polygons, which I tried with no success. That is what I'm trying to accomplish.

edit2: dismiss this question. It's not possible. The workaround I'm applying is to save the polygons in SVG and parse them to get a list of nodes. then will feed that list to flash to calculate the intersection and areas on runtime.

View 2 Replies

ActionScript 3.0 :: Detect The Point Of Intersection Of A Line And A Triangle?

Nov 27, 2010

There is some information but I couldn't figure it out:How can I detect if a line intersects with a triangle ? And how can I detect the point of intersection in AS3 ?

View 1 Replies

Flex :: LineSeries AreaSeries On AreaChart - Get The Intersection Point?

May 4, 2010

I am plotting an AreaSeries and a LineSeries on a AreaChart using Flex 3 in built chart components. I want to code a custom item renderer for LineSeries to be shown at the intersection points where LineSeries crosses AreaSeries.

View 1 Replies

Actionscript 3 :: Intersection Of Parabolic Curve And Line Segment?

Aug 31, 2010

I have an equation for a parabolic curve intersecting a specified point, in my case where the user clicked on a graph.

// this would typically be mouse coords on the graph
var _target:Point = new Point(100, 50);
public static function plot(x:Number, target:Point):Number{
return (x * x) / target.x * (target.y / target.x);

[code]......

View 4 Replies

ActionScript 3.0 :: JPG/PNG Encoding And Vectors?

Dec 4, 2010

So I have recently created a Tshirt design application where a user can draw on a tshirt / add text / upload images. Though I am having a few problems. Problem #1: Using the pen tool I can only allow users to draw and reset the drawing using the graphics class, no idea how to create an eraser tool

Q1 - Is there any way to create the eraser? Problem #2: Once a user saves the shirt it is later encoded into a JPG or PNG With no way of editing the shirt in the future.

Q2 - I thought of saving the locations of the shapes / items they uploaded onto the shirt and colors and later re-creating the shirt once loaded. But ran into one problem that is I cannot save the drawing they did using the pen tool, only the location of the objects (MC's) is there any better way to creating this?

View 5 Replies

Shape Tween Grayed Out Between 2 Vectors

Sep 2, 2009

I have two vector graphics I imported to my stage and want to do a shape tween between them. But shape tween is grayed out. The images are imported Illustrator EPS's. I attached two screenshots.

Attachments: Picture 1.jpg (144.1 K)
Picture 2.jpg (141.9 K)

View 1 Replies

ActionScript 1/2 :: Any Way To Transform TextField To Vectors?

Oct 11, 2009

I very often use animated text (rather for menu titles than paragraphs) in my flash works and the render of fonts is usually quite irregular. What I now do is convert the alphabet + figures of the font I am using to vectors (Ctrl + B) on the scene and then make movieclips with each letter, which I store in the library ready for AS to call them. The rendering quality is comparably better. The truth is I've never had to make more than, say 50 clips "by hand", but it would still make my life easier and save me dull time/work if there was a way with AS to transform a text field to vectors...

View 5 Replies

Flex :: Access The Vectors Of A Font?

Dec 18, 2009

How would you define/create generative typography ? I thought also of some sort of "intelligent" adaption. For example a font that uses serifs in certain condition or not... Are there some findings in how you could access the vectors of a font in actionscript ?

View 2 Replies

Actionscript 3 :: Vectors: Using Getters And Setters?

Jan 7, 2010

Is there a way to use getters and setters for Vectors?Say, in my Main class, I would like to write

myVector.push(item);

and in another class, I have written:

public function get myVector():Vector.<int> {
return _opponentCardList;
}
public function set myVector(myVector:Vector.<int>):void {
_myVector = myVector;
}

This doesn't really work as you have to set _myVector to a Vector. But what if you just want to push(), pop() or splice?

View 1 Replies

Actionscript 3 :: FullScreenSourceRect Is Pixelating Vectors

Sep 21, 2010

I'm currently developing a Flash website that incorporates an flv player. The controls on the player's skin are all vectors. I've set it up so that when you hit fullscreen on the player controls a fullScreenSourceRect is created which is working great. However when the the player is full screen, the once crisp vectors are now pixelated as if they were a bitmap.

View 3 Replies

Actionscript 3 :: Modify Vectors At Runtime

Mar 3, 2011

Is there any way to modify the vectors of a DisplayObject at runtime? I import a Sprite or MovieClip on my application, and I want to be able to modify the vectors that composes it. A close approach is to use Graphic class, but it always renders below the Sprite, it can't clear the original graphic, and it can't modify the vectors, only draw new things. And if this is totally impossible, I would like to know how I can call Sprite.graphics.drawXXX, so that the graphics are rendered above the Sprite.

View 1 Replies

Actionscript :: Bitmaps Faster Than Vectors?

Apr 11, 2011

I'm working on a project which draws circles continuously at framerate and animates them around the stage and I'm running into performance issues.

I'm already converting all objects to bitmapData as soon as they become static. My question is, will converting the circles to bitmapData as soon as they are drawn increase performance? In other words, is animating say, 200 bitmaps (with transparency) faster than 200 vector circles?

Are there any drawbacks to this technique? (I'm thinking opacity problems maybe?)

If they were more complex shapes than circles would the answer be different?

View 3 Replies

Actionscript 3 :: Serializing Vectors In A Sub-class

May 11, 2011

I'm trying to serialize data in AS3 but am running into a frustrating problem. Originally I had problems with "myObjClass" not being convertible, but after I discovered "registerClassAlias" I got things working allright. Some time later, I added vectors to the myObjClass. I ran into trouble with Vector Strings before, as was reported here:

[Code]...

View 4 Replies

ActionScript 3.0 :: Vectors Become Pixelated When Scaled?

Nov 16, 2009

I'm trying to scale down some vectors but when i do they become pixelated. So I tried putting then in a container and scaling down the container, but pixelation still occurs.can anyone tell me why this is happening and a possible work around?Here is the function from my class:

private function addItems():void
{
addChild(itemsContainer);

[code].......

View 3 Replies

ActionScript 3.0 :: Serializing A Vector Of Vectors?

Jun 6, 2010

I'm trying to serialize a vector of vectors:

Code:
package
{

[code]......

View 1 Replies

ActionScript 3.0 :: Alternative To Vectors / Arrays

Nov 20, 2010

I'm programming in AS3 using CS3, which only seems to publish using versions of flash up to and including V9.Anyway, I'd like to use some vectors of integers in my program, but these seem only available in Flash Player 10. I'd rather not use Arrays as these cannot be assigned "types" and are a bit slow and clunky.Is there an alternative to the vector class (i.e. arrays for which we can assign types)? If not, is there a way that I can bring flash player 10 into the File >> Publish Settings menu so that I can use vectors?To me this is a remarkable issue to have, because typed arrays are an essential part of any serious programming.

View 4 Replies

ActionScript 3.0 :: Declaring And Populating 2D/3D Vectors?

May 30, 2011

I'm trying this for creating and populating a 2D Vector of Integers:

Code:
var vector2D:Vector.<Vector.<uint>> = new Vector.<Vector.<uint>>
[
new <uint>[1, 2, 3, 4, 5, 6, 7, 8, 9],
new <uint>[10, 11, 12, 13, 14, 15, 16, 17, 18]
];

And well, that's not working...For this program I'm working on I'll also need to declare and populate a 3D vector.

View 9 Replies

Actionscript 3.0 :: Vectors Become Pixelated When Scaled

Nov 16, 2009

I'm trying to scale down some vectors that have a z position set (other than zero) and they are becoming pixelated. So flash is obviously bitmapping the vectors.

Does anyone know of a work around to stop the pixelation?

Here is the function from my class:

private function addItems():void
{
addChild(itemsContainer);
// make the items.

[Code].....

View 1 Replies

ActionScript 3.0 :: THICK Line-line Intersection?

Aug 15, 2009

Finding the intersection point of 2 line segments is easy enough.

But now I need to test wether a line with thickness intersects another (non-thick) line.

My idea is to actually perform 2 tests, one at the top and bottom of the thickness of the line. Does that make sense? Is there a better way to do it? I dont need the intersection point, just a boolean yes or no.

View 7 Replies

360 Degree Product Rotation

Apr 11, 2007

I have a client that wants a product to rotate around its axis for a full 360 degree view of the product. The final view needs to be draggable - so a user can use their mouse to turn it left or right. I took photos of the product in 10 degree increments and created a movie clip - but I can't figure out how to get it so a user can control the view: turning the product left or right.

View 3 Replies

F8 :: Spin A Product 360 Degrees?

Nov 1, 2007

Wanting to spin a product 360 degrees.

View 1 Replies

ActionScript 3.0 :: Dynamically Altering A Shape's Vectors?

Jul 26, 2009

I don't know if i'm in the right category here.I have a line in the center of the screen, and i want it to bend. i guess i have to use vector operations? (I mean, what Illustrator uses. visuals, with vectors instead of pixels). I want to be able to set points, so that the line bends towards that point. And the color under the line should be different than the color above the line. Does anyone know how to get started on something like this?

View 1 Replies

ActionScript 3.0 :: Instantiate Dynamically Named Vectors?

Jun 18, 2010

i'm trying to create a dynamically named Vector.  i have a critical project deadline tomorrow, and this small problem is holding back continued development i've adapted my code from this example [URL]...yet am getting an error message (see below).  here is what i have:

[Code]...

View 9 Replies

ActionScript 3.0 :: Passing And Handling Vectors Wrong?

Jun 3, 2011

So I have the code of two classes (I can't post any actual code as its way too long - even broken up But I can give you a sample of simmilar aspects)
 
public class ClassA
{
private var objectString:Vector.<String>; // create a new vector to hold items - this will be passed

[Code]....
 
Yes I have an understanding of vectors so pointing me to the documentation may be worthless. As I have read it hundred times. I would not be posting here if I didnt. How ever I may have missed something.
 
Upon debugging this I see that Class A has a vector that now contains one element -> "hello." When I pass that vector on Object container is null. Whats worse is now I return a null vector list and pass on a null vector list and trace should in theory show me null.
 
In java this is how I would pass vectors and arrays around and I believe some one showed me this is how you do it in actionscript.

View 32 Replies

AS3 :: Vectors Doesn't Rezise When Resize MovieClip?

Mar 20, 2011

I have bit of a strange problem. In have a MovieClip i resize, but the vector graphic doesn't resize with it. It's a Movieclip in my library that i'm linking to and when I insert it on my stage, it resizes just fine.

I have exported the MovieClip as an AS Object called: TabTemplate and the i extend it in a class called Tab.

I set some text in the textfield defined in it and the resize the tab accordingly. but the graphic doesnt follow :(

I'm not used to AS3's ways of doing things, so there might be something i've missed.

Here's the class code:

package mypackage {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;

[Code]....

There is actually two issues going on here:

1) The textWidth isn't return the correct number. I have some shadow on the text and i don't know if that screws anything up. But otherwise I'm just using Regular Arial.

2) The mask of the 'Tab' + it's vector background isn't resizing when I'm resizing the MovieClip, like it does in Flash it self.

View 2 Replies

ActionScript 2.0 :: Cache All Of The Overlying Vectors As Bitmaps Or Just A Few Or None At All?

Jan 19, 2009

I have a large project with many layers of vector art and one relatively large bitmap underneath them all acting as a map face. I've read that combining types (vector and bitmap) is not good. My question is .. Is it worth it to cache all of the overlying vectors as bitmaps or just a few or none at all?

Everything is pretty static except for the dragging of the map face which moves everything as one movieclip. My CPU is doing overtime when I run the project because I am dealing with 100-300 small movieclips on top of the map. This is my first major project so I am now trying to optimize a cumbersome file.

View 0 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved