1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gfx/box_f.h"
7 #include "base/strings/stringprintf.h"
11 std::string
BoxF::ToString() const {
12 return base::StringPrintf("%s %fx%fx%f",
13 origin().ToString().c_str(),
19 bool BoxF::IsEmpty() const {
20 return (width_
== 0 && height_
== 0) ||
21 (width_
== 0 && depth_
== 0) ||
22 (height_
== 0 && depth_
== 0);
25 void BoxF::Union(const BoxF
& box
) {
33 float min_x
= std::min(x(), box
.x());
34 float min_y
= std::min(y(), box
.y());
35 float min_z
= std::min(z(), box
.z());
36 float max_x
= std::max(right(), box
.right());
37 float max_y
= std::max(bottom(), box
.bottom());
38 float max_z
= std::max(front(), box
.front());
40 origin_
.SetPoint(min_x
, min_y
, min_z
);
41 width_
= max_x
- min_x
;
42 height_
= max_y
- min_y
;
43 depth_
= max_z
- min_z
;
46 BoxF
UnionBoxes(const BoxF
& a
, const BoxF
& b
) {