Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9082113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:28:44+00:00 2026-06-16T20:28:44+00:00

I’m fairly new to python (and completely new to Python OO), but I’m working

  • 0

I’m fairly new to python (and completely new to Python OO), but I’m working with a fairly complicated class that I’m struggling to understand but that I need to edit. To help understand what’s going on I’m trying to pull data out of an object but everything I do is just returning “classname object at address”.

Could someone explain to me how I’d go about printing, say, the vertex field in this object:

class Halfedge(object):
    def __init__(self, edge=None, marker=Edge.LEFT):
        self.left = None    # left Halfedge in the edge list
        self.right = None   # right Halfedge in the edge list
        self.qnext = None   # priority queue linked list pointer
        self.edge = edge    # edge list Edge
        self.marker = marker
        self.vertex = None  # Site()
        self.ystar = BIG_FLOAT

    def __eq__(self, other):
        return self.ystar == other.ystar and \
               self.vertex.x == other.vertex.x

    def __lt__(self, other):
        if self.ystar  == other.ystar:
            return self.vertex.x < other.vertex.x
        else:
            return self.ystar < other.ystar

    def left_reg(self, default):
        if not self.edge:
            return default
        elif self.marker == Edge.LEFT:
            return self.edge.reg[Edge.LEFT]
        else:
            return self.edge.reg[Edge.RIGHT]

    def right_reg(self, default):
        if not self.edge:
            return default
        elif self.marker == Edge.LEFT:
            return self.edge.reg[Edge.RIGHT]
        else:
            return self.edge.reg[Edge.LEFT]

    def is_point_right_of(self, point):
        """Returns True if <point> is to right of halfedge.
        """
        edge = self.edge
        topsite = edge.reg[1]
        right_of_site = point.x > topsite.x

        if(right_of_site and self.marker == Edge.LEFT):
            return True

        if(not right_of_site and self.marker == Edge.RIGHT):
            return False

        if(edge.a == 1.0):
            dyp = point.y - topsite.y
            dxp = point.x - topsite.x
            fast = 0
            if ((not right_of_site and edge.b < 0.0) or \
                (right_of_site and edge.b >= 0.0)):
                above = dyp >= edge.b * dxp
                fast = above
            else:
                above = point.x + point.y * edge.b > edge.c
                if(edge.b < 0.0):
                    above = not above
                if (not above):
                    fast = 1
            if (not fast):
                dxs = topsite.x - (edge.reg[0]).x
                above = (edge.b * (dxp*dxp - dyp*dyp)) < \
                        (dxs*dyp*(1.0+2.0*dxp/dxs + edge.b*edge.b))
                if(edge.b < 0.0):
                    above = not above
        else:  # edge.b == 1.0
            yl = edge.c - edge.a * point.x
            t1 = point.y - yl
            t2 = point.x - topsite.x
            t3 = yl - topsite.y
            above = t1*t1 > t2*t2 + t3*t3

        if(self.marker == Edge.LEFT):
            return above
        else:
            return not above

    def intersect(self, other):
        """Create a new site where the Halfedges edge1 and edge2 intersect.
        """
        edge1 = self.edge
        edge2 = other.edge
        if (edge1 is None) or (edge2 is None):
            return None

        # if the two edges bisect the same parent return None
        if edge1.reg[1] is edge2.reg[1]:
            return None

        d = edge1.a * edge2.b - edge1.b * edge2.a
        if almost_equal(d, 0.0):
            return None

        intersect_x = (edge1.c * edge2.b - edge2.c * edge1.b) / d
        intersect_y = (edge2.c * edge1.a - edge1.c * edge2.a) / d
        if edge1.reg[1] < edge2.reg[1]:
            halfedge = self
            edge = edge1
        else:
            halfedge = other
            edge = edge2

        right_of_site = intersect_x >= edge.reg[1].x
        if ((right_of_site and halfedge.marker == Edge.LEFT) or
            (not right_of_site and halfedge.marker == Edge.RIGHT)):
            return None

        # create a new site at the point of intersection - this is a new
        # vector event waiting to happen
        return Site((intersect_x, intersect_y))

I know this is pretty simple stuff, but thanks for any help.

Edit: The entire class I’m using can be found at:

https://bitbucket.org/mozman/geoalg/src/5bbd46fa2270/geoalg/voronoi.py

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:28:46+00:00Added an answer on June 16, 2026 at 8:28 pm

    Assuming you have a Halfedge instance – let’s call it my_halfedge – you access any of its properties with the dot notation. So, for the vertex property, you’d do my_halfedge.vertex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.