1

**General / Re: PixelMath vector line**

« **on:**

**Today**at 07:18 »

Hi Pepe!

I hope i did not misunderstand your question concerning drawing vectors with PixelMath

So, I dont know a vector function in PixelMath directly.

But,

there is a function in PixelMath to create a line segment.

Its called d2seg and it draws a line from x_orig,y_orig, to x_target,y_target.

Simply test it with

d2seg(100,100, 200,200)

will draw a line segment from x=100,y=100 to X=200,y=200

So, to use your arguments Angle and length you can extend the formula by calculating

the target x,y by using Sin and Cos

To make the formula standard and only change the variables you

define in PixelMath in

And the PixelMath expression than is:

For future segment drawings simply change the values in the Symbols and you get a line segment

depending on the angle va and the length l.

in the final expression i wrote 1-d2seg(.... to create a one pixel wide white line with black background if you only us

d2seg(... you will get a black line with white background

if there are questions let me know.

Yes you could extend this formula by using the width and height infos of the actual image

to place the start x,y calculated... etc...

Gerald

I hope i did not misunderstand your question concerning drawing vectors with PixelMath

So, I dont know a vector function in PixelMath directly.

But,

there is a function in PixelMath to create a line segment.

Its called d2seg and it draws a line from x_orig,y_orig, to x_target,y_target.

Simply test it with

d2seg(100,100, 200,200)

will draw a line segment from x=100,y=100 to X=200,y=200

So, to use your arguments Angle and length you can extend the formula by calculating

the target x,y by using Sin and Cos

To make the formula standard and only change the variables you

define in PixelMath in

**Symbols: xv=100, yv=100, va=45, l=100, xv1, yv1**And the PixelMath expression than is:

**xv1=(cos((va/180*pi()) ) * l); yv1=(sin((va/180*pi()) )*l); 1-d2seg(xv,yv,xv+xv1,yv-yv1)**For future segment drawings simply change the values in the Symbols and you get a line segment

depending on the angle va and the length l.

in the final expression i wrote 1-d2seg(.... to create a one pixel wide white line with black background if you only us

d2seg(... you will get a black line with white background

if there are questions let me know.

Yes you could extend this formula by using the width and height infos of the actual image

to place the start x,y calculated... etc...

Gerald