Straight line

          if (mousecounter == 0)
          slope = (newx-oldx)/(newy-oldy);
          slope2 = (newy-oldy)/(newx-oldx);
          ++mousecounter;
oldx = oldx+ slope;
oldy = oldy + slope2;I need desperate.......... I need to be able to take the old coordinates (oldx. oldy) and move them in straight line to (newx, newy). The problem is, its a mouse click, and it will need to be able to move forward, backward, side to side, etc in a straight line...... Suggestions?

Did you figure out your other problem (with getting x or y always 0)?
Anyway, your slope should be the same for changing both x and y coordinates. Why do you have two slopes? You can't add slopes to x or y coordinates--that makes no sense.
You have an object at (oldx, oldy).
The user clicks on (newx, newy).
The line between the points is:
(y-oldy)/(x-oldx) = (newy - oldy)/(newx - oldx)Or (expressing y in terms of x):
y = (((newy - oldy)/(newx - oldx))*(x - oldx)) + oldyOr:
y = (((newy - oldy)/(newx - oldx))*(x)) + (oldy - ((newy - oldy)/(newx - oldx))*oldx)If you pick an x, you can calculate the matching y on that line. To move in n steps:
x = oldx;
x_n = oldx + (((newx - oldx)/n) * oldx);Put those x values in the equation for y, and you will get the corresponding y. Of course, you could just do the same as you did for x:
y = oldy;
y_n = oldy + (((newy - oldy)/n) * oldy);

Similar Messages

  • Problem with creating a straight line with polygamo lasso

    I am having a problem with polygamo lasso. when i create a triangle or a rechtangle in straight line it is turn out the line become not straight. I don't what did i wrong, was always working fine till today. YOu can see the pic the top line lookslike a step.

    Ihope I did right, was not sure how to save as channel.

  • How to draw only straight line instead of angled one??

    Dear friends,
    I saw a very good code posted by guru here(I think is camickr),
    But I tried to change it and I hope to draw only straight line instead of angled one, can you help how to do it??
    Thanks so much.
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class DrawingArea extends JPanel
         Vector angledLines;
         Point startPoint = null;
         Point endPoint = null;
         Graphics g;
         public DrawingArea()
              angledLines = new Vector();
              setPreferredSize(new Dimension(500,500));
              MyMouseListener ml = new MyMouseListener();
              addMouseListener(ml);
              addMouseMotionListener(ml);
              setBackground(Color.white);
         public void paintComponent(Graphics g)
              // automatically called when repaint
              super.paintComponent(g);
              g.setColor(Color.black);
              AngledLine line;
              if (startPoint != null && endPoint != null)
                   // draw the current dragged line
                   g.drawLine(startPoint.x, startPoint.y, endPoint.x,endPoint.y);
              for (Enumeration e = angledLines.elements(); e.hasMoreElements();)
                   // draw all the angled lines
                   line = (AngledLine)e.nextElement();
                   g.drawPolyline(line.xPoints, line.yPoints, line.n);
         class MyMouseListener extends MouseInputAdapter
              public void mousePressed(MouseEvent e)
                   if (SwingUtilities.isLeftMouseButton(e))
                        startPoint = e.getPoint();
              public void mouseReleased(MouseEvent e)
                   if (SwingUtilities.isLeftMouseButton(e))
                        if (startPoint != null)
                             AngledLine line = new AngledLine(startPoint, e.getPoint(), true);
                             angledLines.add(line);
                             startPoint = null;
                             repaint();
              public void mouseDragged(MouseEvent e)
                   if (SwingUtilities.isLeftMouseButton(e))
                        if (startPoint != null)
                             endPoint = e.getPoint();
                             repaint();
              public void mouseClicked( MouseEvent e )
                   if (g == null)
                        g = getGraphics();
                   g.drawRect(10,10,20,20);
         class AngledLine
              // inner class for angled lines
              public int[] xPoints, yPoints;
              public int n = 3;
              public AngledLine(Point startPoint, Point endPoint, boolean left)
                   xPoints = new int[n];
                   yPoints = new int[n];
                   xPoints[0] = startPoint.x;
                   xPoints[2] = endPoint.x;
                   yPoints[0] = startPoint.y;
                   yPoints[2] = endPoint.y;
                   if (left)
                        xPoints[1] = startPoint.x;
                        yPoints[1] = endPoint.y;
                   else
                        xPoints[1] = endPoint.x;
                        yPoints[1] = startPoint.y;
         public static void main(String[] args)
              JFrame frame = new JFrame("Test angled lines");
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              DrawingArea d = new DrawingArea();
              frame.getContentPane().add( d );
              frame.pack();
              frame.setVisible(true);
    }

    Change the AngledLine class to store two points instead of 3 points (I would rename the class to be StraightLine). The code is much simpler because you just store the starting and ending points and you don't need to calculate the middle point.

  • When I record an audio track, there is a waveform. When I stop recording, the waveform disappears and becomes a straight line. It also disappears from the track edit window. But the sound is there. How can I stop the waveform from disappearing?

    When I record an audio track using Logic Pro X, there is a visible waveform which appears as I record. When I stop recording, the waveform disappears and becomes a straight line. It also disappears from the track edit window. But the sound is still there. How can I stop the waveform from disappearing? And can I do something to view it after it has disappeared? Anyone know the anser?

    In Logic:
    Preferences/Audio Set Recording Delay to 0 <zero>
    This should always be set to zero unless a specific set of circumstances exist and you're audio drivers do not report position correctly.
    On occasion, usually when importing a Logic 9 project, Logic-X randomly changes this to a negative/positive number.  It's actually a bug in Logic, as it should always display the waveform.

  • Ssrs 2008 r2 straight line within a matrix

    In an SSRS 2008 R2 new report have placed a matrix on the end of the report for information the user wants to see at the end of the report. The user wants to place a straight line between the different infomation sections in the tablix. Here are the problems
    I am having:
    1. In a row I would like to merge 2 cells together so that a line placed within the matrix is the same length. The problem is that I do not know how to merge the cells.
    2. When I drag a line into a cell in the matrix, the line is not straight. The line points to an angle. I have tried to change the properties of the line on the endpoint values but that has not worked. Thus can you tell me how to make the line placed within
    a matrix cell to be straight?

    Take a look at this post for inserting a horizontal (or vertical) line into a tablix cell:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/397d6dc4-766a-43c9-9706-5370a2bfaeb4/insert-line-into-table?forum=sqlreportingservices
    For merging cells, you simply select a set of contiguous cells, right-click, merge cells. There is a catch of course. The catch is that all of the cells you are trying to merge must be in the same scope. Below are some screenshots showing a simple Matrix
    with 1 column group and 1 row group.
    As you can see in this screenshot, I have selected 2 adjacent cells that are both in the same scope, and merge cells is available.
    In this screenshot, I have selected 2 adjacent cells that are not in the same scope. The left cell is only scoped by the row group while the cell on the right is scoped by both the row and the column group. As a result, I cannot merge the cells.
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • How to get rid of or at least easily fix random Position A to Positon B 'archs'?(want straight line)

    Hey,
    I hope i can describe my question correctly: is there a way to tell after effects that i want to default every position edit to be a straight path/arch (i'm actually looking for a lack of 'arch'--I just want a straight line) instead of defaulting to a seemingly random arch that i then find very tedious if not impossible to fix, even by manipulating vertice box 'arms' while holding alt? in other words, can i tell the program that, from now on, 'position A' and 'position B' must be traveled between in a straight line ONLY, never any erronious archs? i hope i described it well enough without being too familar with technical terms
    thanks

    Rick's pointing you in the right direction.
    Details are here:
    http://help.adobe.com/en_US/aftereffects/cs/using/WS3878526689cb91655866c1103906c6dea-7d99 a.html#WS3878526689cb91655866c1103906c6dea-7d98a

  • My Macbook Pro (OSX 10.6.7 2.26 GHz Intel Core 2 Duo) has started misbehaving on me. When I'm working, the cursor will start spontaneously moving to the left in a straight line, and randomly right clicking on things.  If I close the computer and open it b

    my Macbook Pro (OSX 10.6.7 2.26 GHz Intel Core 2 Duo) has started misbehaving on me. When I'm working, the cursor will start spontaneously moving to the in a straight line, and randomly right clicking on things.
    If I close the computer and open it back up, it sometimes stops for a little while, then will spontaneously start again. Any help would be truly appreciated. Thanks!

    See this knowledge base article. Also, you might want to update to 10.6.8 (don't know that that will fix your problem, but it's the latest version of Snow Leopard).
    Clinton

  • Can I extend the slideshow horizontal in a straight line but not full page up and down?

    Can I extend the slideshow horizontal in a straight line across the page end to end, but not full page up and down?

    Hi
    Please check these videos for help :
    https://www.youtube.com/watch?v=BDgERSf2a5k
    https://www.youtube.com/watch?v=diUtfwFGI1w
    Thanks,
    Sanjit

  • Why can I only paint straight lines in Photoshop CS6?

    I am trying to paint something that I have wanted to for a while now, and Photoshop is presenting some troubles for me. I can not paint curves, and instead, only straight lines without pen pressure (Size, opacity, the likes.) The result of my efforts is the same as if I were to draw a dot (click once in other words), press shift, and make another dot somewhere else. It's just straight lines no matter what.
    I am currently on an Emachines computer running Windows 7, Photoshop CS6 and this is the first time I have bothered with the brush tool in Photoshop.
    I hope this information is useful for someone to help me so that I may paint freely. Thank you for reading.

    Trevor Dennis wrote:
    Bulbabooty wrote:
    What do you mean by the first sentence you said?
    It is possible that the Shift key is stuck on your keyboard.  If you add a Type layer and some text, you'll see if that is the case or not.  Unlikely I'd have thought, but things can get jammed between the keys, and you need to eliminate this possibility before moving on to other possibilities.
    Oh, I see. No, the shift key is not the problem it seems. I have a feeling that it's the brush I'm using.

  • Simplifying Straight Line Paths

    Hey all,
    new to the forum and really struggling with something at the moment, Using Illustrator CS4
    I've imported a map from a DWG prepared in Archicad (vector based architecture software)
    This map shows roads and buildings (they are paths in illustrator) and as you would imagine the roads are curved but rather than being drawn with curves they are composed of many many straight line paths and as I'm meaning to have a model laser cut from the Illustrator file I need to join these paths into longer paths so the laser cutting doesn't take forever.
    As far as I can see it's fairly simple to simplify the number of anchor points on a curved path using the Object>Path>Simplify tool but simplifying multiple straight line paths that only have the slightest deviation in angle seems harder, or at least I can't work it out.
    I have attached an image, The areas highlighted in green are examples of areas where there are too many paths and just one or two paths would be fine. It would be fine to either convert the paths to curved paths or just simply reduce the number of straight line paths that compose the curves.
    Hope someone can help, Thx for your time
    The

    Apart from the current problem, you should take a look at the free plugin "Kartografie-Funktionen" if you do this kind of stuff regularly. http://www.ika.ethz.ch/plugins/index.html
    It has a tool for simplifying paths, which works slightly different than Illustrator's

  • Making a straight line aligned with text and adjusting length

    i am trying to make a simple straight line above some text in after effects cs5 that lines up with the beginning and end of the text. Not touching or anything. Nothing special. then a line perpendicular to it of a different stroke size.
    Also i want it to draw or fill in.
    first of all, if i dont get the line length perfect the first time, and i try to adjust the length, then the stroke width changes, also the scale.
    this is maddening because if i am making other pieces that i will animate together, i want them to be the same. and every time i try to adjust the line length, it changes everything...
    or do i just make all lines and type graphics in illustrator or photoshop and import them...and make a mask.  I almost think that all those extra steps might be easier...(sarcasm)
    any tips on this as this super basic task is turning into a headache?
    thx in advance.

    Well, because if you dont get it exactly correct and you want to make it longer or shorter, not only does that change, but the stroke starts scaling. So now you have simply a shorter line, you have a line that appears the same but is inevitably different point sizes and different scales that are maddening to match. I am animating several iterations of a kind of type/line template in 3d space. So i have made each on its own composition that is not 3d.
    i thought you would be able to just click on the end of the line/path and make the line itself shorter or longer like in illustrator. Also when the scale changes, it changes its position slightly from its anchor point....

  • Newbe - straight line with different curves at each end

    I'm generally not using Illustrator as I'm sure you can tell. I need several curly brackets, but none will really do as they will cover varioius lengths and should be the same size. It looks like the easiest way will simply be to create one putting two straight lines together, but I cannot even determine how to get a curved end at one end of the line - yet alone a second different curve on the other end. Thanks. Rick

    shiesl,
    For the curly bracket shape you may consider quarter circles at the ends, and a pair at the middle, all with the same radius.
    You may:
    1) Create a circle with the Ellipse Tool and cut it into quarters at the Anchor Points; you may then use all the bits or just one or two of them with copies,
    2) Place the first quarter with the inner end where you want the first straight part to start (on one side of the intended straight part),
    3) Place the second quarter (corresponding to a 180 degrees rotation) oppositely (on the other side of the intended straight part) where you want the firrst straight part to end,
    4) With the Direct Selection Tool select both inner ends and Object>Path>Join, now you have one half curly bracket,
    5) Object>Transform>Reflect, Align the two halves, and Join them at the midlle.
    For different lengths, you may Direct Select the two Anchor Points at either end and move them away from the middle (you may use arrow, Object>Transform>Move, or other ways).
    If you just want roundings at the ends, you may simplify the suggestion here, just having the second one on the same side in 3) and finish with 4).

  • SDO_NN and SDO_WITHIN_DISTANCE return distance on way or on straight line?

    Hi to all,
    I want ask you if the distance between 2 points computed with SDO_NN and SDO_WITHIN_DISTANCE is a distance on the way that connects these two points (for example 35 miles) or is a distance on a straight line that connects these two points (for example 20 miles)?
    thank you very much.

    Ok Jack, thank you.
    I understood. For straight line I mean a distance that doesn't pass for the streets but on the earth without considering the streets (distance as the crow flies).
    Do you confirm that this result is a distance as the crow flies?
    Thank you very much.

  • Loan transaction - straight line or reducing balance method

    Hi all,
    i have a question here.  It is regarding interest rate instrument product in SAP-TRM.
    For interest rate instrument/ loan product can we set whether the interest can be charged either on straight line method or reducing balance method?
    Your soonest feedback is highly appreciated.
    Thanks.

    Hi,
    Both are supported. For straight line method you can choose the Interest Form - Amount and for Reducing balance method choose - Fix or Variable Rate option in interest structure.
    Regards
    Prasad AV

  • Flash CC 2014 Drawing with tablet creates straight lines

    I recently downloaded Flash and Photoshop from the free student service and when I use my tablet Intuos4, the lines you see are drawn but it's also draws in the far left, the start of the straight line is where I actually start but for some reason it draws a straight line shifting to the left.
    I checked if it was my shift key from the keyboard and tablet to see if it was jammed, but on the bottom half of the canvas you notice that when I do use my shift key it still draws straight lines and still goes to the far left.
    I updated my drivers for my tablet and it still didn't do anything, it doesn't happen to any other program like Photoshop, it detects the tablet and draws normally.
    Help please?
    http://oi59.tinypic.com/2r6igjq.jpg

    Hi.
    I am experiencing some serious issues with flash professional cc and my drawing tablet. Every time I place my drawing pen on the surface of my tablet, while in flash professional cc, a long straight line darting to the left and beyond my canvas occurs. I haven't messed with any of my settings for I just got the tablet today as well as the flash professional cc program. It's very frustrating and is hindering my work. If this problem is not resolved, I will take my business and money elsewhere.
    Thank you.
    All specs:
    Flash Professional CC 2014 v. 14.1.0.96
    Windows 7
    Monoprice Graphic Drawing Tablet 10x6.25 inch 4000 LPI, 200 RPS, 2048 Levels

  • How can i get Radio buttons  and parameters  in a Single Straight Line

    Hi Experts,
    How can i get Radio buttons  and parameters  in a Single Straight Line...
    Example:
       r1 r2 p1 p2.....
    Cheers,
    Priya
    Points granted.

    Write the following code for the selection screen:
    DECLARATION OF PARAMETERS.
    SELECTION-SCREEN: BEGIN OF BLOCK select WITH FRAME TITLE text-001,
                      BEGIN OF LINE.
                      SELECTION-SCREEN COMMENT 1(10) FOR FIELD p_detail.
                      PARAMETERS p_detail RADIOBUTTON GROUP r1 DEFAULT 'X'.
                      SELECTION-SCREEN COMMENT 25(10)  FOR FIELD p_summry.
                      PARAMETERS p_summry RADIOBUTTON GROUP r1.
    SELECTION-SCREEN: END OF LINE,
                      END OF BLOCK select.
    this will solve your poblem surly. reward the points if you find helpful
    Regards,
    Siddarth

Maybe you are looking for

  • Asterisks in all input fields eg search boxes logins etc but not in word or email

    HPE-475uk Windows 7 Premium Home Hi My PC started playing up a couple of days ago Every time I tried to login from the Windows  login screen in the box for my password suddenly a line of asterisks appear sometimes before I even type. Eventually after

  • Demo Backend System

    Is there any demo backend and gateway system SAP provides that we can use with SAP River RDE for developing Fiori applications.

  • How to view unconsumed LCR in the queue?

    Hi all, suppose I capture DML of tables A and B on my queue but I only configure the apply process to consume messages for table A. I suppose that my queue will grow indefinitely since messages relative to table B are not consumed, am I correct? How

  • LocalStorage not storing between sessions

    Hi, When I load panel whitch conteining below HTML code: <!doctype html> <html> <head> <meta charset="utf-8"> <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){    $('#save

  • [SOLVED] Full upgrade + LVM = Error on boot

    Arch64 Just ran a full upgrade ( -Syu). /boot has it's own ext2 partition /home /var etc are managed with LVM on the reminder of the disk (there are 3 other disks that are mounted on different points under /home/user_name.  They are not part of the L