Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions A vector drawn line between two points

  • A vector drawn line between two points

  • Paul Carlin

    February 10, 2007 at 8:28 am

    Currently I am drawing a line between two points using the Effects>Generate>Beam.

    Problem is when I move towards the layer in 3D Space, the layer pixelates and falls apart. I tried increasing the size of the solid by 400% and scaling it down 25%, which gives me some improvement, but I’m looking for a better way of doing this.

    Is there some way of doing this with a vector based tool?

    Perhaps a text layer?

  • Brian Charles

    February 10, 2007 at 4:34 pm

    Have you tried pre-composing the beam?

  • Mike Clasby

    February 10, 2007 at 7:03 pm

    I can’t quite replicate you problem, but Render>Audio Waveform is Vector based, it actually exports as very small SWF files. Just draw a 2 point mask with the pen tool. Anyway, just set the displayed samples to a high number. Maybe it will help.

  • Paul Carlin

    February 10, 2007 at 7:04 pm

    Let me clarify with an incredibly long explanation…

    I am creating an animation that follows a bad guy (let’s call him the target) by tracking his cell phone, using the various signal strengths (SNR) of nearby cell towers (CellID or CID) to triangulate the position. This “T-Hunting” is a somewhat inaccurate process, so I have a bit of wiggle built-in.

    Since I am the God of this particular universe, I am determining the path of the target. In my animation, I use the Effect>Generate>Beam effect to draw a line from the cell tower to the target using a solid layer the size of the comp. In addition, I am using equations to determine the distance to the cell towers, changing the thickness and opacity.

    Since this is supposedly a very sophisticated Satellite view, I want to be able to zoom in from a wide shot of Barcelona to a close up of the neighborhood. I have learned from past experience that creating a 10K (or more) pixel comp is render intense and crash prone. So I decided to make the comp the final size (Square Pixel PAL Widescreen), make the layers 3D and use a camera to zoom in. This allows for me to layer various scaled images on the same Z plane, yet of different scales, and be able to move closer to the layers without losing resolution. Mission accomplished as far as being able to zoom.

    Here

  • Paul Carlin

    February 10, 2007 at 8:06 pm

    This is what I get. Wide on left, Close-up on the right.

  • Mike Clasby

    February 10, 2007 at 9:39 pm

    Firstly, me not gots AE7, I’m a low-life6.5, so I can’t open your comp above, but it looks good.

    The sample pics you sent, I’m wondering where the waveform came from, if the Solid that has the 2 point mask is chosen as the Audio Layer (in the plug-in) then you get a solid beam, much like the effect Beam you were using. No audio as an Audio source and no waveform, unless this is an AE7 thing and it finds an Audio Source for you?

    Anyway, try this, when I pull a 3D Beam comp into a new comp, I get your banded beams, but with the “Continuously Rasterize” with on, I get a solid beam again. The only way I can get your Banded Beams is when they’re precomped and not Continuously Rasterized. So precomp your 3D Solid layer (with the Beam on it) then Continuously Rasterize.

    Worth a try.

  • Paul Carlin

    February 10, 2007 at 11:02 pm

    Whew! I figured it out.

    I will never questions my high school teachers again with questions like, “When will I ever need to know trigonometry in real life?”

    I created a yellow line in Illustrator and imported it into AE. With a lot of help from Pythagoras of Samos I was able to calculate the angle between the points and the distance. Apply the angle to the line (offset with a zero anchor point on the x axis). Scale along the X axis using the distance times 100 over the lines width.

    I realize this is all gibberish. So here is the comp

  • Lu Nelson

    February 3, 2009 at 9:44 am

    Hey Paul,

    I realize your post is from a year ago; but I’m trying to do something similar. Could you repost the comp you did somewhere? I assume the line you created in Illustrator has to be of a specific size, like 100 px long or something like that, so you can calculate the math correctly no?

    Thanks,

    LMN

    Lu Nelson
    Berlin, Germany

  • Paul Carlin

    February 3, 2009 at 6:56 pm

    Ah, old memories…

    I created a Yellow Line in Illustrator that was 900 x 10 pixels. I actually made it a dashed line for creative reasons.

    Then my idea was to anchor the left edge of the line to the first point, and then determine the x scale and angle of rotation to make it to the second point. Here’s how…

    Set the anchor point to 0,5 (Left edge, half of height)

    Use an expression to set the position to match the first point. For example, thisComp.layer(“CellTower 01”).transform.position

    Use another expression to determine the scale:
    CellTower = thisComp.layer(“CellTower 01”).transform.position;
    Target = thisComp.layer(“Dan Green”).transform.position;
    BeamLength = length(CellTower, Target)*(100/width);
    [BeamLength-.5,10]

    Celltower and Target are the two points.
    BeamLength is the distance between the two points multiplied times 100/the width of the line.
    Then subtract .5 to shrink it a little.

    That takes care of the X scale (line length), but what about the line width or thickness? I actually used the following expression for the scale…

    First I created an expression slider effect named Camera Scale and gave it this equation:

    //Value should range from zero to one
    CellTower = thisComp.layer(“CellTower 01”).transform.position;
    Target = thisComp.layer(“Dan Green”).transform.position;
    Delta = sub(CellTower, Target);
    Math.abs(length(Delta))*.0006

    By tweeking the value .0006 I was able to get this value to vary from zero to one (approximately) based on the shortest and longest distance.

    Then I used this expression for the Scale:

    CellTower = thisComp.layer(“CellTower 01”).transform.position;
    Target = thisComp.layer(“Dan Green”).transform.position;
    BeamLength = length(CellTower, Target)*(100/width);
    CameraScale = Math.abs(-thisComp.layer(“Camera Scale”).effect(“Camera Scale”)(“Slider”));
    [BeamLength-.5,(CameraScale*22+4)]

    The Camera Scale allowed me to adjust the width of the line based on the “zoom” factor. Since this was determined by tracking existing footage, I needed to link it to existing tracking data using this expression:

    .8-thisComp.layer(“Helicopter Track Axis”).transform.scale[0]/1200

    Of course, you will need to come up with something on your own for this.

    See how easy this stuff is?

    One last thing… the Rotation. Here is the expression for Rotation:

    CellTower=thisComp.layer(“CellTower 01”).transform.position
    Target=thisComp.layer(“Dan Green”).transform.position;

    // Find the length of side a
    SideA = sub(CellTower, Target)[1];

    // Find the length of side b
    SideB = sub(CellTower, Target)[0];

    //Find the Angle between them
    radiansToDegrees(Math.atan2(SideA, SideB))+180;

    For the fun of it, I had the transparency and Hue of the line change based on the “signal strength”. I’ll let you figure that one out.

    Looking back at all this I realise that it can be greatly simplified, but I had a job to do and didn’t have time for housecleaning. If it works, don’t fix it.

    To see my finished comps, go to my web page and watch the “Hidden Camera Footchase Sequence” on my Portfolio page.

    http://www.sparkmedia.com

  • Lu Nelson

    February 4, 2009 at 8:58 am

    Wow, thanks Paul for the detailed explanation! I thought about your first post for a while, and old Pythagoras, and worked out a technique; but it was helpful to read how you did it too. There’s something addictive about working out these little solutions….;)

    Lu Nelson
    Berlin, Germany

Viewing 1 - 10 of 10 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy