Create a bounding box from two points with a customizable width

bounding box python
bounding box code
bounding box regression
rhinocommon bounding box
tensorflow bounding box
bounding box object detection
bounding box object detection, python
how-to-get-the-coordinates-of-the-bounding-box-in-yolo-object-detection

I have two points making a line, I want to see if a point is ruffly on the line. To do this I need to create a bounding box/ a rectangle which has a width D outwards/ perpendicular to the line. I was following this website for guidance but seem to have implemented it wrongly. Any help would be appreciated.

  private static bool IsInside(GPS Point1, GPS Point2)
        {
            GPS VectorV = new GPS()
            {
                Longitude = Point1.Longitude - Point2.Longitude,
                Latitude = Point1.Latitude - Point2.Latitude
            };

            GPS VectorW = new GPS()
            {
                Longitude = -1 / VectorV.Longitude,
                Latitude = -1 / VectorV.Latitude
            };

            double W = Math.Sqrt(Convert.ToDouble(VectorW.Latitude * VectorW.Latitude) + Convert.ToDouble(VectorW.Longitude * VectorW.Longitude));

            GPS NewVector = new GPS()
            {
                Longitude = Convert.ToDecimal(Convert.ToDouble(VectorW.Longitude) / W),
                Latitude = Convert.ToDecimal(Convert.ToDouble(VectorW.Latitude) / W),
            };

            decimal D = 5;

            GPS DisplacmentVector = new GPS()
            {
                Longitude = (D / 2) * NewVector.Longitude,
                Latitude = (D / 2) * NewVector.Latitude
            };

            GPS BPoint1 = new GPS() { Longitude = Point1.Longitude + DisplacmentVector.Longitude, Latitude = Point1.Latitude + DisplacmentVector.Latitude };
            GPS BPoint2 = new GPS() { Longitude = Point1.Longitude - DisplacmentVector.Longitude, Latitude = Point1.Latitude - DisplacmentVector.Latitude };
            GPS BPoint3 = new GPS() { Longitude = Point2.Longitude + DisplacmentVector.Longitude, Latitude = Point2.Latitude + DisplacmentVector.Latitude };
            GPS BPoint4 = new GPS() { Longitude = Point2.Longitude - DisplacmentVector.Longitude, Latitude = Point2.Latitude - DisplacmentVector.Latitude };
}

 public partial class GPS
    {
        public decimal Longitude { get; set; }
        public decimal Latitude { get; set; }

        public GPS() { }

        public GPS(decimal longitude, decimal latitude) {
            Longitude = longitude;
            Latitude = latitude;
        }
    }

When you have a vector v= A to B = {xb-xa, yb-ya} = {vx, vy} there are two directions for its perpendicular: one heading right of A->B, the orther heading left of A->B.

One perpendicular vector is w1= {-vy, vx} (towards left), the other is w2= {vy, -vx} (towards right). Note than w1 = -w2.

To get the four corners you may use w1 or w2 or both. It's a matter of the used signs and the order of resultant points.

Let's use w1. Your definition is wrong. Use this instead:

GPS VectorW = new GPS()
{
    Longitude = - VectorV.Latitude,
    Latitude =  VectorV.Longitude
};

Adobe Photoshop CS4: Comprehensive Concepts and Techniques, You can draw multiple shapes on a single layer Resizing Shapes To resize a shape, press CTRL+T to display the shape's bounding box. The number of sides then becomes the number of points on the star. Rectangle Polygon Rectangle, Rounded Rectangle, Ellipse, Custom Shape Options Arrowheads, Width, Length,  By using the BoundingBox class, you can directly access bbox.width and bbox.height. Although you can access the coordinates at bbox[0], bbox[1], , you can avoid mixing up the coordinates by accessing them using bbox.minx, bbox.maxx, bbox.miny and bbox.maxy .

You are overcomplicating things. There are 3 cases for the line:

  1. Line parallel with x axis (y coordinate of both points are equal), easy to calculate
  2. Line parallel with y axis (x coordinate of both points are equal), easy to calculate

for the rest you need dx and dy:

cos(θ) = dx / (D / 2) => dx = cos(θ) * (D / 2)
sin(θ) = dy / (D / 2) => dy = sin(θ) * (D / 2)

θ = 90 - φ
tan(φ) = a / b => φ = atan(a / b)

Thats it.

AutoCAD Platform Customization: VBA, AddMText(insertionPoint, width, textString) Their arguments are as follows: retVal doubles that defines the t insertion point of the text object. height or width The an AcadText object or overall width of the boundary box of an AcadMText object. The following code statements add two new single-line text objects to model  You can create a bounding box for a multibody, single body, or sheet metal part. You can also create a bounding box for any cut list item in a cut list, independent of the type of solid or sheet metal bodies in the item. The bounding box is represented by a 3D sketch and is based, by default, on the X-Y plane.

In the end I decided to go for a different approach and instead found the distance away from the line the point was. It follows the same logic that it must be X distance away from the line.

For guidance I followed/ used this code.

User Interfaces in VB .NET: Windows Forms and Custom Controls, Windows Forms and Custom Controls Matthew MacDonald a bounding rectangle specified by a pair of coordinates, a height, and a width. Draw|Line() and Draw|Lines() Draws a line connecting the two points specified by coordinate pairs. Create a bounding box from two points with a customizable width. I have two points making a line, I want to see if a point is ruffly on the line. To do this I need to create a bounding box/ a rectangle which has a width D outwards/ perpendicular to the line.

BoundingBox Objects, They are the simplest closed shape type in planar, represented by two points This creates the smallest BoundingBox object that encloses all of these points: possible to create a BoundingBox from a center point, specifying its width and height yourself if you create your own custom shape classes with planar primitives. For any outdoor location in the game, the mod needs at least two pairs of points to calculate the map location. The two pairs of points are required to create a bounding box (top-left corner and bottom-right corner) with which we can calculate the pixel position on the map from the current tile position in the location.

BoundingBox Structure, Represents the value of two points in a bounding box defined by the two extreme corner points. This box is therefore An Empty box is an invalid structure that has negative width. Inflate the box with custom amounts in all directions. Inflating  Implementation of a 3D bounding box. This class provides an implementation of a bounding box. A bounding box describes a volume in space that bounds a piece of geometry. The box is defined by two points which describe the minimum and maximum corners of the box.

13.3. Object Detection and Bounding Boxes, In the next few sections, we will introduce multiple deep learning models In object detection, we usually use a bounding box to describe the target The bounding box is a rectangular box that can be determined by the x and y axis coordinates in the We can draw the bounding box in the image to check if it is accurate. “Hit” Testing¶. All closed shapes, including bounding boxes, have a contains_point() method for testing if a point is inside or outside of the shape. For bounding boxes, this is an extremely simple, and fast test so often a hit test of a complex shape will first do a test against the shape’s bounding box to quickly eliminate points that are not near the shape at all.

Comments
  • Just calculate the distance from the point to the line and see if it's within your "ruffly" constraint.
  • Can this be further simplified to atan2(a, b)?
  • @meowgoesthedog Yes