Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/brownvc/deep-synth
31 March 2020, 06:46:23 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
Revision b800e11290b763b58e7d3b30329769a7b77cd12a authored by kwang-ether on 14 June 2019, 23:53:57 UTC, committed by kwang-ether on 14 June 2019, 23:53:57 UTC
remove csv
1 parent 79eaa7f
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • b800e11290b763b58e7d3b30329769a7b77cd12a
    No releases to show
  • 291f7df
  • /
  • deep-synth
  • /
  • data
  • /
  • projection.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:b800e11290b763b58e7d3b30329769a7b77cd12a
origin badgedirectory badge
swh:1:dir:54a08d56a0b0dcf8d8570e9e94f242cb08cebac3
origin badgecontent badge
swh:1:cnt:e1b5a4d3d0eca8e1c8444550ed97bb8e74cb5c27
origin badgesnapshot badge
swh:1:snp:0f10b5007a9962ed82323ed2242cf08ba5544645

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: b800e11290b763b58e7d3b30329769a7b77cd12a authored by kwang-ether on 14 June 2019, 23:53:57 UTC
remove csv
Tip revision: b800e11
projection.py
import numpy as np
import math
import scipy.misc as m

class ProjectionGenerator():
    """
    Generates projection between original 3D space and rendered 2D image space
    Given the position of the room
    """
    def __init__(self, room_size_cap=(6.05,4.05,6.05), zpad=0.5, img_size=512):
        """
        See top_down.TopDownView for explanation of room_size, zpad and img_size
        """
        self.room_size_cap = room_size_cap
        self.zpad = zpad
        self.img_size = img_size
        self.xscale = self.img_size / self.room_size_cap[0]
        self.yscale = self.img_size / self.room_size_cap[2]
        self.zscale = 1.0 / (self.room_size_cap[1] + self.zpad)

    def get_projection(self, room):
        """
        Generates projection matrices specific to a room,
        need to be room-specific since every room is located in a different position,
        but they are all rendered centered in the image
        """
        xscale, yscale, zscale = self.xscale, self.yscale, self.zscale

        xshift = -(room.xmin * 0.5 + room.xmax * 0.5 - self.room_size_cap[0] / 2.0)
        yshift = -(room.ymin * 0.5 + room.ymax * 0.5 - self.room_size_cap[2] / 2.0)
        zshift = -room.zmin + self.zpad

        t_scale = np.asarray([[xscale, 0, 0, 0], \
                              [0, zscale, 0, 0], \
                              [0, 0, yscale, 0], \
                              [0, 0, 0, 1]])
        
        t_shift = np.asarray([[1, 0, 0, 0], \
                              [0, 1, 0, 0], \
                              [0, 0, 1, 0], \
                              [xshift, zshift, yshift, 1]])

        t_3To2 = np.dot(t_shift, t_scale)
    
        t_scale = np.asarray([[1/xscale, 0, 0, 0], \
                              [0, 1/zscale, 0, 0], \
                              [0, 0, 1/yscale, 0], \
                              [0, 0, 0, 1]])
        
        t_shift = np.asarray([[1, 0, 0, 0], \
                              [0, 1, 0, 0], \
                              [0, 0, 1, 0], \
                              [-xshift, -zshift, -yshift, 1]])
        
        t_2To3 = np.dot(t_scale, t_shift)

        return Projection(t_3To2, t_2To3, self.img_size)

class Projection():
    def __init__(self, t_2d, t_3d, img_size):
        self.t_2d = t_2d
        self.t_3d = t_3d
        self.img_size = img_size
    
    def to_2d(self, t=None):
        """
        Parameters
        ----------
        t(Matrix or None): transformation matrix of the object
            if None, then returns room projection
        """
        if t is None:
            return self.t_2d
        else:
            return np.dot(t, self.t_2d)

    def to_3d(self, t=None):
        if t is None:
            return self.t_3d
        else:
            return np.dot(t, self.t_3d)

    def get_ortho_parameters(self):
        bottom_left = np.asarray([0,0,0,1])
        top_right = np.asarray([self.img_size,1,self.img_size,1])
        bottom_left = np.dot(bottom_left, self.t_3d)
        top_right = np.dot(top_right, self.t_3d)
        return (bottom_left[0], top_right[0], bottom_left[2], top_right[2], bottom_left[1], top_right[1])
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API