From patchwork Wed Oct 2 05:49:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 21466 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 82600BD80A for ; Wed, 2 Oct 2024 05:50:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D6CF963528; Wed, 2 Oct 2024 07:50:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Y/fALEiG"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1366B6350B for ; Wed, 2 Oct 2024 07:50:14 +0200 (CEST) Received: from ideasonboard.com (unknown [5.77.88.238]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 134F263F; Wed, 2 Oct 2024 07:48:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727848121; bh=ZmVN2B7zYL3NekOhgCe3US8FkMSisJ8m755y49T2gqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/fALEiGHdnAh/RY8FFu68kLN89Q1aat5CfXU7DDAqjD/6odJFZXyqQeeloTrb1RX U4D+gmk9RFiGEuENA57lqoBWApMs32rxS1JUdM8yXyFvVqlV21Lb73mlcyWB7UXtQw hEJ9+ZENAZk8p18GojdtTYcHOX3RyOminp5841uI= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Jacopo Mondi , Harvey Yang , David Plowman Subject: [PATCH v10 1/5] libcamera: geometry: Clarify Rectangle's top-left corner Date: Wed, 2 Oct 2024 07:49:58 +0200 Message-ID: <20241002055002.6271-1-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241001191354.55056-1-jacopo.mondi@ideasonboard.com> References: <20241001191354.55056-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The libcamera::Rectangle class allows defining rectangles regardless of the orientation of the reference system where a rectangle is used in. This implies that, depending on the reference system in use, the rectangle's top-left corner, as defined by libcamera, doesn't correspond to the visual top-left position. ^ | | ------------------- | ^ | h | | | y| o---->------------- | w -------------------------------> (0,0) x (0,0) x ------------------------------> | w y| o---->------------- | | | h | v | | ------------------- | V Clarify that a Rectangle's top-left corner corresponds to the point with the smaller x and y coordinates and that the horizontal and vertical dimensions are obtained by positive increments along the corresponding axes. Signed-off-by: Jacopo Mondi Reviewed-by: Harvey Yang Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/libcamera/geometry.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index 000151364c7f..85a7f53a6f6c 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -594,6 +594,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr) * * Rectangles are used to identify an area of an image. They are specified by * the coordinates of top-left corner and their horizontal and vertical size. + * By convention, the top-left corner is defined as the corner with the lowest + * x and y coordinates, regardless of the origin and direction of the axes. * * The measure unit of the rectangle coordinates and size, as well as the * reference point from which the Rectangle::x and Rectangle::y displacements @@ -611,6 +613,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr) * \param[in] x The horizontal coordinate of the top-left corner * \param[in] y The vertical coordinate of the top-left corner * \param[in] size The size + * + * The rectangle's top-left corner is the point with the smaller x and y values. */ /** @@ -620,6 +624,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr) * \param[in] y The vertical coordinate of the top-left corner * \param[in] width The width * \param[in] height The height + * + * The rectangle's top-left corner is the point with the smaller x and y values. */ /** @@ -632,11 +638,15 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr) /** * \var Rectangle::x * \brief The horizontal coordinate of the rectangle's top-left corner + * + * The rectangle's top-left corner is the point with the smaller x and y values. */ /** * \var Rectangle::y * \brief The vertical coordinate of the rectangle's top-left corner + * + * The rectangle's top-left corner is the point with the smaller x and y values. */ /** @@ -685,6 +695,9 @@ Point Rectangle::center() const /** * \fn Point Rectangle::topLeft() const * \brief Retrieve the coordinates of the top left corner of this Rectangle + * + * The rectangle's top-left corner is the point with the smaller x and y values. + * * \return The Rectangle's top left corner */