Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Drawing of the arrowhead on the end of drown Line.
  FAQ FAQ  Forum Search   Register Register  Login Login

Drawing of the arrowhead on the end of drown Line.

 Post Reply Post Reply
Author
Message Reverse Sort Order
Michael_67 View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Aug 15
Location: DE
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michael_67 Quote  Post ReplyReply Direct Link To This Post Topic: Drawing of the arrowhead on the end of drown Line.
    Posted: 12 Aug 15 at 4:03PM
Originally posted by mLipok mLipok wrote:

But I do not worry about this as my dev.environment take care about that, and all works properly :)

C # is much more restrictive in this case :)
Thank you again. You have helped me a lot with your algorithm.



Edited by Michael_67 - 12 Aug 15 at 4:04PM
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (1) Thanks(1)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 15 at 1:31PM
ah I see.
You have right.
But I do not worry about this as my dev.environment take care about that, and all works properly :)



Edited by mLipok - 12 Aug 15 at 1:31PM
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
Michael_67 View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Aug 15
Location: DE
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michael_67 Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 15 at 12:53PM
Vertical line: _QPDF_Arrow(100, 20, 100, 200 ...
$iX12 = $iX2 - $iX1 is in this case 0, $iY12 / $iX12 - division by zero

Right to left: _QPDF_Arrow(100, 20, 10, 200 ... X2 < X1 draws not <--- but >---

Best Regards
Michael
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 15 at 12:37PM
Originally posted by Michael_67 Michael_67 wrote:

However, if the arrow direction is right to left, arrow head direction is false. And in case of a vertical line, it will lead to error in the line
Local $iArrowRadian = ATan($iY12 / $iX12)

Can you show example of parameters, for my function ?
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
Michael_67 View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Aug 15
Location: DE
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michael_67 Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 15 at 5:26PM
My Function in C# (simplified, arrow head only, fix angle and length):

        private static void DrawArrowHead(double startX, double startY, double endX, double endY)
        {
            double headAngleDegree = 15;
            double headLength = 10;

            var headAngle = headAngleDegree * (Math.PI / 180);
            var deltaX = endX - startX;
            var deltaY = endY - startY;

            double lineSlopeAngle;
           
            if (deltaX == 0)
            {
                if (endY > endX)
                {
                    lineSlopeAngle = Math.PI / 2;
                }
                else
                {
                    lineSlopeAngle = -Math.PI / 2;
                }
            }
            else
            {
                lineSlopeAngle = Math.Atan(deltaY / deltaX);
            }

            if(deltaX >= 0)
            {
                lineSlopeAngle += Math.PI;
            }
           

            var rightLineAngle = lineSlopeAngle + headAngle;
            var leftLineAngle = lineSlopeAngle - headAngle;

            var rightLineEndX = endX + Math.Cos(rightLineAngle) * headLength;
            var rightLineEndY = endY + Math.Sin(rightLineAngle) * headLength;

            var leftLineEndX = endX + Math.Cos(leftLineAngle) * headLength;
            var leftLineEndY = endY + Math.Sin(leftLineAngle) * headLength;

            pdfLibrary.DrawLine(endX, endY, rightLineEndX, rightLineEndY);
            pdfLibrary.DrawLine(endX, endY, leftLineEndX, leftLineEndY);
        }

Back to Top
Michael_67 View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Aug 15
Location: DE
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michael_67 Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 15 at 8:01AM
Thank you very much!
That looks pretty good.

I'll translate it in C #, if I have the time.

However, if the arrow direction is right to left, arrow head direction is false. And in case of a vertical line, it will lead to error in the line
Local $iArrowRadian = ATan($iY12 / $iX12)







Edited by Michael_67 - 11 Aug 15 at 5:24PM
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (1) Thanks(1)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 10 Aug 15 at 6:44AM
maybe this way:

#Region TESTING
_QPDF_Arrow(10, 10, 100, 10, 10, 10, 0.1, 1)

; #FUNCTION# ====================================================================================================================
; Name ..........: _QPDF_Arrow
; Description ...: Draw Arrow with ArrowHeads
; Syntax ........: _QPDF_Arrow($iX1, $iY1, $iX2, $iY2[, $iArrowHeadLenPercent = 10[, $iArrowHeadAngleDegree = 10[,
;                  $iArrowThickness = 0.1[, $iArrowHeadThickness = 0.1]]]])
; Parameters ....: $iX1                      - an integer value.
;                  $iY1                      - an integer value.
;                  $iX2                      - an integer value.
;                  $iY2                      - an integer value.
;                  $iArrowHeadLenPercent     - [optional] an integer value. Default is 10. In relation to the length of the arrows.
;                  $iArrowHeadAngleDegree    - [optional] an integer value. Default is 10.
;                  $iArrowThickness          - [optional] an integer value. Default is 0.1.
;                  $iArrowHeadThickness      - [optional] an integer value. Default is 0.1.
; Return values .: None
; Author ........: mLipok
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.quickpdf.org/forum/drawing-of-the-arrowhead-on-the-end-of-drown-line_topic3155.html
; Example .......: No
; ===============================================================================================================================
Func _QPDF_Arrow($iX1, $iY1, $iX2, $iY2, $iArrowHeadLenPercent = 10, $iArrowHeadAngleDegree = 10, $iArrowThickness = 0.1, $iArrowHeadThickness = 0.1)
Local $oQP
If _QPDF_CreateObjectAndUnlock($oQP) = 1 Then

$oQP.SetOrigin($__eQPDF_SORIGIN_TopLeft);
$oQP.SetMeasurementUnits($__eQPDF_MUNITS_Milimeters)
$oQP.SetLineWidth($iArrowThickness)
$oQP.SetLineCap(1)
$oQP.Drawline($iX1, $iY1, $iX2, $iY2)
Local $iX12 = $iX2 - $iX1
Local $iY12 = $iY2 - $iY1

; Assign a Local constant variable the approximate PI number.
Local Const $PI = _Radian(180)

$iArrowHeadAngleRadian = _Radian($iArrowHeadAngleDegree)

; Tan(angle) = Y / X
; Atan(X / Y) = angle
Local $iArrowRadian = ATan($iY12 / $iX12)
Local $iReverseArrowRadian = $iArrowRadian + $PI

Local $iArrowLength
If $iY12 = 0 Then
$iArrowLength = $iX12
Else
; Sin(angle) = Y / Len
$iArrowLength = $iY12 / Sin($iArrowRadian)
EndIf

Local $iArrowHeadLength = $iArrowLength * $iArrowHeadLenPercent / 100

Local $iRadianTiltedToTheRight = $iReverseArrowRadian + $iArrowHeadAngleRadian
Local $iRadianTiltedToTheLeft = $iReverseArrowRadian - $iArrowHeadAngleRadian

; tg(angle) = Y / X
; ctg(angle) = X / Y
; sin(angle) = Y / $iArrowHeadLength
; cos(angle) = X / $iArrowHeadLength

$oQP.SetLineWidth($iArrowHeadThickness)
$oQP.Drawline($iX2, $iY2, $iX2 + Cos($iRadianTiltedToTheRight) * $iArrowHeadLength, $iY2 + Sin($iRadianTiltedToTheRight) * $iArrowHeadLength)
$oQP.Drawline($iX2, $iY2, $iX2 + Cos($iRadianTiltedToTheLeft) * $iArrowHeadLength, $iY2 + Sin($iRadianTiltedToTheLeft) * $iArrowHeadLength)

_QPDF_Display($oQP)
EndIf
EndFunc   ;==>_QPDF_Arrow
#EndRegion TESTING






Edited by mLipok - 10 Aug 15 at 6:51AM
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
Michael_67 View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Aug 15
Location: DE
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michael_67 Quote  Post ReplyReply Direct Link To This Post Posted: 07 Aug 15 at 2:38PM
Originally posted by mLipok mLipok wrote:

You must calculate the angle of slope of the line.
Then determine the opening angle and length arrowhead.
Calculate endpoints for each edge arrowhead and draw a triangle.

Thank you.

That is my idea too. This should be possible with the trigonometric functions.
I was just hoping someone already has a ready-made solution.



Edited by Michael_67 - 07 Aug 15 at 2:39PM
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 07 Aug 15 at 1:33PM
You must calculate the angle of slope of the line.
Then determine the opening angle and length arrowhead.
Calculate endpoints for each edge arrowhead and draw a triangle.

Interesting task.
Currently I am on vacation.
I am happy to take care of this deeply when I come back, and maybe a little earlier.

Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
Michael_67 View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Aug 15
Location: DE
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michael_67 Quote  Post ReplyReply Direct Link To This Post Posted: 07 Aug 15 at 8:54AM
Hello.

What's the easiest way, to draw an arrowhead (two short lines or a triangle does not matter) at the end of with DrawLine(double StartX, double StartY, double EndX, double EndY) drawn line?

A snippet, best in C #, would be nice.

QuickPDF Version 11.14
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store