nx_metadata_sdk  1.0
Metadata SDK
rect.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2 
3 #pragma once
4 
5 #include <nx/sdk/analytics/point.h>
6 
7 namespace nx::sdk::analytics {
8 
9 struct Rect
10 {
12  Rect() = default;
13 
14  Rect(float x, float y, float width, float height): x(x), y(y), width(width), height(height) {}
15 
16  Rect(Point topLeft, float width, float height):
17  x(topLeft.x), y(topLeft.y), width(width), height(height)
18  {
19  }
20 
25  float x = -1;
26 
31  float y = -1;
32 
37  float width = -1;
38 
43  float height = -1;
44 
50  Point center() const { return Point(x + width / 2, y + height / 2); }
51 
52  bool isValid() const
53  {
54  return x >= 0 && y >= 0 && width >= 0 && height >= 0
55  && x + width <= 1 && y + height <= 1;
56  }
57 };
58 
59 } // namespace nx::sdk::analytics
float x
Definition: rect.h:25
float y
Definition: point.h:21
float width
Definition: rect.h:37
float y
Definition: rect.h:31
Point center() const
Definition: rect.h:50
Definition: consuming_device_agent.cpp:22
float height
Definition: rect.h:43
Definition: point.h:7
float x
Definition: point.h:16
Definition: rect.h:9