473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to add two points together

Hi again NG. Is there an easier way than I have shown to add two
points together. All I can find in the docs is a shortcut to add a
point and a size together (ie Point.op_Addition).
Thank you
Colin

Dim pt1 As New Point(10, 10)
Dim pt2 As New Point(3, 5)

//lots of other code

//Adding point2 to point1, is there a hidden operator that
//would enable me to go for example pt1.add(pt2) ?
pt1.X+=pt2.X
pt1.Y+=pt2.Y
Nov 20 '05 #1
3 4302
No, either add "pt1.X+=pt2.X" as you have shown or
"pt1=Point.op_Addition(pt1,New Size(pt2))" as you imply.
Hexathioorthooxalate
"Colin McGuire" <co***********@lycos.co.uk> wrote in message
news:ab**************************@posting.google.c om...
Hi again NG. Is there an easier way than I have shown to add two
points together. All I can find in the docs is a shortcut to add a
point and a size together (ie Point.op_Addition).
Thank you
Colin

Dim pt1 As New Point(10, 10)
Dim pt2 As New Point(3, 5)

//lots of other code

//Adding point2 to point1, is there a hidden operator that
//would enable me to go for example pt1.add(pt2) ?
pt1.X+=pt2.X
pt1.Y+=pt2.Y


Nov 20 '05 #2
Colin,
As Hexathioorthooxalate pointed out, you need to use Point.op_Addition as he
demonstrated or use the code you demonstrated.
//Adding point2 to point1, is there a hidden operator that
//would enable me to go for example pt1.add(pt2) ? Addition for Point is an overloaded operator, the method that implements
this overloaded operator is Point.op_Addition. Current versions VB.NET
(VS.NET 2002 & VS.NET 2003) do not support overloaded operators, hence the
statement Hexathioorthooxalate gave. When we get to Whidbey (VS.NET 2004)
VB.NET will support overloaded operators! Woo Hoo!!

Which means you will then the more 'natural':

' VB.NET 2004 syntax (Whidbey)
pt1 += pt2

Which converts pt2 to a Size, then adds this size to pt1, all under the
covers!

Note: Point.op_Addition is normally hidden in VS.NET, you need to use
"Tools - Options - Text Editor - Basic - General - Hide advanced members" to
show or hide advance members of classes, such as overloaded operators.

Hope this helps
Jay

"Colin McGuire" <co***********@lycos.co.uk> wrote in message
news:ab**************************@posting.google.c om... Hi again NG. Is there an easier way than I have shown to add two
points together. All I can find in the docs is a shortcut to add a
point and a size together (ie Point.op_Addition).
Thank you
Colin

Dim pt1 As New Point(10, 10)
Dim pt2 As New Point(3, 5)

//lots of other code

//Adding point2 to point1, is there a hidden operator that
//would enable me to go for example pt1.add(pt2) ?
pt1.X+=pt2.X
pt1.Y+=pt2.Y

Nov 20 '05 #3
"Colin McGuire" <co***********@lycos.co.uk> schrieb
Hi again NG. Is there an easier way than I have shown to add two
points together. All I can find in the docs is a shortcut to add a
point and a size together (ie Point.op_Addition).
Thank you
Colin

Dim pt1 As New Point(10, 10)
Dim pt2 As New Point(3, 5)

//lots of other code

//Adding point2 to point1, is there a hidden operator that
//would enable me to go for example pt1.add(pt2) ?
pt1.X+=pt2.X
pt1.Y+=pt2.Y

Dim pt1 As New Point(10, 10)

pt1.Offset(3, 5)

or, if it has to be a point:

Dim pt1 As New Point(10, 10)

pt1.Offset(pt2.x, pt2.y)

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kyler Laird | last post by:
I'm trying to do some georeferencing - using points of known location (ground control points, GCPs) on an image to develop a polynomial that can be used to approximate the locations of other...
4
by: Jim Land | last post by:
I've got an image and an image map, and they work fine together. See it here: http://www.jim-land.com/testing/MapPage01.htm But the image map has way too many points (vertices) in its 87...
6
by: Mark | last post by:
Hi, My page has a table with many columns such that the right-side of the table gets chopped off when printed. I specify a table width of 100%, but otherwise no cell dimensions are specified. ...
0
by: Ferdi Smit | last post by:
I wrote a generic algorithm for boost.graph to merge two vertices, ie. the end-points of an edge are joined together as if they are a single vertex. I'm currently doing this by creating a new...
6
by: Steve Jorgensen | last post by:
I tried to fix a problem for a client today in which report sections and even individual text controls in some of their reports are being split across page boundaries. Of course, I was thinking...
6
by: Tamir Khason | last post by:
Let's say I have Point and I want to sort it circle way (e.g. 2;2.4;1,8;2,8,5;4;8,2;7,1;4 The algo for this is: if ((p.X<p.X & p.Y<Avg(p).Y & p.Y<Avg(p).Y) | (p.X>p.X & p.Y>Avg(p).Y &...
8
by: bevanward | last post by:
Hi all I have a large data set of points situated in 3d space. I have a simple primary key and an x, y and z value. What I would like is an efficient method for finding the group of points...
2
elamberdor
by: elamberdor | last post by:
Hi All! Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map, ..well now I want to load in...
5
by: JD | last post by:
Hi, There are about 10+ 3-D points on the same line. I want to find the two end points from these points. The efficiency is not an issue because there are only 10 points or so. I just need a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.