Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Scripting Math Formulas
PostPosted: December 7th, 2007, 12:49 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

I am trying to create a script to clone a line based on its start point and end point, but the math/trig component is beyond my math skills.

(The pub requires a way to save and reload these lines, which can't be done using the v6 drawing functions (for example, draw line), since lines drawn using these drawing functions in a frame can't have their positions gotten, saved or reloaded. Cloned lines, however, can be saved/reloaded.)

The attached jpeg screenshot (see attached zip folder) illustrates the challenge: A line (Line C) is created and is placed outside of the diagram's canvas (it could even be placed off-screen, for example, -50,-50).

There are 2 shape symbols needing to be connected from point A to point B.

The user, in runtime, first clicks, using a right click trigger, on point A, which has a GetMousePosition() script, stores the position to variables (can get and store posAX and posAY). Then using a left click trigger to click on point B, they can get that position, with its posBX and posBY, store these in variables.

Here's where I get stuck on the math, trying to correctly place, size and angle Line C's clone: Line C can be scripted, in the same left click trigger used for point B (above). Line C is cloned and, using SetDisplayData, that line clone can be placed to connect Points A and B
(can't use SetObjectDimensions because before cloning there is no object or Object Dimensions data that can be returned by GetObjectDimensions)

But SetDisplayData() needs to be specified. While the start and end points (AX, AY, BX, BY) of the line are know from the mouse position variables, my hazy recollection of geometry and trig taken about 4 decades ago tells me that some complex math/trig calculations are needed to specify the cloned line's correct placement, including scaling, angle, etc. connecting the points A and B.

This formula has been beyond my math and scripting skill: any help would be appreciated.

Kind Regards,


You do not have the required permissions to view the files attached to this post.

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: December 7th, 2007, 1:33 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Stephen,

:? What I remember from Geometry is only 'the shortest distance btw 2 pts is....'.

I haven't digested the problem described yet. Lost me w/ ax ay bx by. Some thoughts.

1. could you mimick a solution by using the object centers of the two shapes, and then use "send object to layer" to hide parts of the Line below shapes.

2. have you looked at the Opus script commands for 'adding points' (vs. drawing line)? I think it still needs a 'seed' drawing, but you might avoid the 'line C' issue AND still capture your coordinate pairs for later reconstruction.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: December 7th, 2007, 3:36 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

Thank you for your reply.

Sorry, I wasn't clearer in describing the issue. Simply put, I need to be able to give an end-user the ability to draw connecting lines between shapes/symbols in their family tree diagram. Since people often need to construct these diagrams by repeatedly returning to correct or add items previously drawn, the drawn lines need to be able to be reloaded and changed, if necessary. So, a static drawing that can't be modified won't work.

Drawing the lines in such a way that their positions/sizes/angles can be gotten, saved, stored, read and reloaded is the challenge. The v6 line drawing or add point features can draw the line in a frame, but these can't be saved and reloaded. Since the end-user may draw as many as 50 lines in a large family tree diagram, if nothing is saved/reloaded, they would have to re-draw every line every time they reurn to work on the diagram: not user-friendly, I'm afraid.

Using a line that can be cloned, scaled, angled and positioned can work, but, so far I haven't been able to devise a script based on my limited scripting and math skills, to get, save, store, read and reload these line. The scripting functions available may not allow for this to be achieved. However, I'm would welcome any solutions that will accomplish this task.

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: December 7th, 2007, 4:40 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Stephen,

I've manged to sneak a quick look at this and modified my orginal drawing app to save and load the drawing.

It's a hack because I've just added to my existing code and the inclusion of the save / load realy needs the coding to be changed because you cannot write objects to a text file - it simple records [object] which is pointless for a reload.

Anyway, I've emailed you the apps, as it shows the concept work and doesn't need complex maths.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: December 7th, 2007, 5:07 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Mack

Interesting variation. It solves one issue: by cloning and using the line drawing in a frame, it allows via naming the clones, to be able to erase them.

However, adding saving seems impossible using a frame, unless there was a way to use the named clones and get enough info about their position, size, angle stored, readable and then reloaded. I can't figure this one out. Can you post the click n'sketch .imp so others can have a look and possibly come up with a script to get/save/read/reload the info?

The other challenge, if the save/reload can be gotten working, would be to identify a specific named clone for erasing. This currently depends on undoing each clone in reverse sequence.

Thanks for the suggestions which point to a possible way forward.

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: December 10th, 2007, 2:54 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

I've made some progress (with the help of forum colleagues), but the test sample for drawing lines still is somewhat awkward, displays an error under some circumstances (if the cloned line2 is left clicked before mouse positions are set-see below).

I'll attach the test .imp: the relevant page is page 4. The 4 shapes ( 2 squares and 2 circles) can be dragged and dropped onto the frame/canvas. The line2 vector is off screen (above) and is cloned by clicking the create line button. Then right-clicking the edge of 1 shape (dragged and dropped onto the frame/canvas sets starting mouse position, while left-clicking on the dge of the second dragged and dropped shape's edge sets the second mouse position. Then left click the cloned line (initially positioned at 650, 50 by the create line button). It should snap in-between the 2 shapes and connect them.

Line1 is currently not used but is included since it has some scripting that needs to be taken into account for the pub.

This is the best I can come up with so far to automate the line drawing. In the actual pub, the lines cloned, sized, angled and positioned need to be saved and then reloaded (also erased, if necessary, but that's another, later challenge) each time the user returns to work on the diagram.

I've tried items like custom triggers and custom actions, but these each have their draw-backs because of the need for "this" in the cloning and were discarded.

Any ideas about how to make this smoother and more functional would be welcome.

Kind Regards,


You do not have the required permissions to view the files attached to this post.

_________________
Stephen


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group